我正在尝试使用 php 和 mysql 从我的数据库中检索 fata。我已经设法从表格的第一行获取数据,但我似乎无法找到让它到达第二行的方法,依此类推。
我的数据库是这样的:(
表中的第一行)
id [int] -> 7
user_id [int] -> 23
user_task_id [int] -> 4
description [varchar] -> Text Text Text Text Text
date_creation [timestamp] -> 2013-07-17
date_end [datetime] -> 0000-00-00
date_conclusion [datetime] -> 0000-00-00
status_id [int] -> 3
notes [text] -> Text Text Text Text Text Text
categoria_id [int] -> 12
entity_id [int] -> 17
(表中的第二行)
id [int] -> 8
user_id [int] -> 6
user_task_id [int] -> 9
description [varchar] -> Text Text Text Text Text
date_creation [timestamp] -> 2013-07-20
date_end [datetime] -> 0000-00-00
date_conclusion [datetime] -> 0000-00-00
status_id [int] -> 4
notes [text] -> Text Text Text Text Text Text
categoria_id [int] -> 18
entity_id [int] -> 10
继承人的代码:
<?php
function get_all_tasks() {
global $connection;
$query = "SELECT * FROM tarefas;";
$tasks_set = mysql_query($query, $connection);
confirm_query($tasks_set);
return $tasks_set;
}
?>
<table class="table_content">
<thead>
<tr>
<td>ID</td>
<td>User Task</td>
<td>Description</td>
<td>Entity ID</td>
<td>Date End</td>
<td>Status</td>
<td>Actions</td>
</tr>
</thead>
<?php
?>
<tbody>
<tr>
<?php
if($task_data = mysql_fetch_array(get_all_tasks())){
foreach ($task_data as $task) { ?>
<tr>
<td><?php echo $task['id'] ?></td>
<td><?php echo $task['user_task_id'] ?></td>
<td><?php echo $task['description'] ?></td>
<td><?php echo $task['entity_id'] ?></td>
<td><?php echo $task['date_end'] ?></td>
<td><?php echo $task['status_id'] ?></td>
<td><?php echo "" ?></td>
</tr>
<?php }}
?>
</tbody>
</table>