doushi3322 2015-04-22 00:25
浏览 48

多维数组,但我无法检索PHP数据

More errors from my most recent project (posted about another thing earlier).

I've been struggling with this error for a few days now. PHP is not my main programming language, nor am I that great at it.

I'm aware that mysql_* should not be used, also.

Anyways. Here's the code snip.

                    <?php
                        $query = "SELECT * FROM events";
                        $result = mysql_query($query);
                        $content = array();            

                        $num = mysql_num_rows($result);
                        if ($num > 0) {
                            while($row = mysql_fetch_assoc($result)) {
                                $content[$row['ID']] = $row;
                            }
                        }
                        if ($num > 0) {
                    ?>
                    <thead>
                        <tr>
                            <th><?php echo implode('</th><th>', array_keys(current($content)));?></th><th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($content as $tablerow): ?>
                        <tr>
                            <td><?php echo implode('</td><td>', $tablerow);?>
                            </td><td><div class="btn-group" role="group" aria-label="Actions"><a class="btn btn-primary" role="button" href="#">New Session</a><a class="btn btn-success" role="button" href="#">Continue Latest</a><a class="btn btn-warning" role="button" href="#">Settings</a><?php echo "<a class='btn btn-danger' role='button' href='/manager/delete?id=".$row."'>Delete</a>"; ?>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>

Sorry for derp formatting. Anyways.

I'm trying to get that delete button to link to ../manager/delete?id=x, where x is the ID for the row. My database is formatted in the way where the ID is in a column labeled "ID". I'm trying to reference each of these rows by this ID... why is this not working?

I've also tried (in the place of row), content[row['ID']], content['ID'], 'row['ID']`, with different case on the ID (uppercase/lowercase).

  • 写回答

2条回答 默认 最新

  • drhgzx4727 2015-04-22 00:31
    关注

    Fred -ii- was correct in his above comment.

    I had tried everything other than $tablerow['ID'].... now you know I guess.

    Thank you for the help everyone. One of the dumbest things I've ever missed while debugging....

    评论

报告相同问题?

悬赏问题

  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序