使用数组isse。但它没有返回任何页面

时间:2014-11-25 18:44:18

标签: php html

使用数组时,我在显示数据库中的选定数据时遇到问题。我认为我遇到的问题是我不知道如何正确输出数组。

PHP代码

$run = array();
$run_query = $sql->query("SELECT * FROM `run_sheet_log`WHERE `user`='$_GET[emp_id]' AND `company_id`='$Company_id' ORDER BY `id` ASC");
while($displayRun = $sql->fetch_array($run_query)){

    $run[] = array('id' => $displayRun['id'],
    'user' => $displayRun['user'],
    'truck' => $displayRun['truck']);
}

HTML代码

<table class="display table shrunk-table" id="run_sheet_table">
    <thead>
        <tr>
            <th>ID</th>
            <th>Carrieing</th>
            <th>Pickup</th>
            <th>Dropoff</th>
            <th>Status</th>
            <th>Action</th>
        </tr>
    </thead>

    <tbody>
        <tr>
        <td><?=$displayRun['id']?></td>
        <td><?=$displayRun['user']?></td>
        <td>France - Calais </td>
        <td>France - Luxemboung </td>
        <td>D <i title="Delivered" class="info c13ADEB glyphicon glyphicon-question-sign"</i></td>
        <td><a href="" id="runs_view" class="btn btn-primary btn-xs">View</a></td>
        </tr>

    </tbody>
</table>

这里是浏览器的视图。 http://gyazo.com/b08c7b3f67c06bd87b90f10751a7b17a

1 个答案:

答案 0 :(得分:1)

在这种情况下,您必须使用$ run数组,即此数组的结构:

$run = [0] = [ 'id' = <value from DB>,
               'user' = <value from DB>     ]
       [1] = [ 'id' = <value from DB>,
               'user' = <value from DB>     ]
.........