我从这个小的PHP和mysql脚本开始。我如何通过 taskupdated列来显示任务?
$query = "SELECT * FROM tasks2 where owner=72";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
echo $row['ownername'];
echo ' - ';
echo $row['tasktitle'];
echo '<br/>';
echo $row['taskdetails'];
echo '<hr/>';
}
答案 0 :(得分:4)
<?php
$query = "SELECT * FROM tasks2 WHERE owner=72 ORDER BY taskupdated";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
echo $row['ownername'];
echo ' - ';
echo $row['tasktitle'];
echo '<br />';
echo $row['taskdetails'];
echo '<hr />';
}
?>
如果您想以其他方式对其进行排序,请改用ORDER BY taskupdated DESC
。
答案 1 :(得分:3)
SELECT * FROM tasks2 where owner=72 ORDER BY taskupdated