0
我有低於我的表是從我的查詢結果,檢索多個數據並顯示到單行
Status |Tasks|Owner|Details
-------------------------------
OnGoing|test |test |2016-09-01
test a
OnGoing|test |test |2016-09-02
test b
OnGoing|test |test |2016-09-03
test c
我希望發生的是,如果任務是像test
和狀態就像是OnGoing
它便會在下面詳細列單行顯示,
Status |Tasks|Owner|Details
-------------------------------
OnGoing|test |test |2016-09-01
test a
2016-09-02
test b
2016-09-03
test c
我目前的查詢,
$sql="SELECT date, status, task, owner, details
FROM tracker
WHERE date BETWEEN '" . $date . "' AND '" . $date1 . "'
ORDER BY date, status";
這裏是我的表中的代碼,
echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'>
<tr>
<th align='center' style='border:dotted 1px;' bgcolor='#66CC00'><font color='#FFFFFF'><strong>Status</strong></font></th>
<th align='center' style='border:dotted 1px;' bgcolor='#66CC00'><font color='#FFFFFF'><strong>Tasks</strong></font></th>
<th align='center' style='border:dotted 1px;' bgcolor='#66CC00'><font color='#FFFFFF'><strong>Owner/s</strong></font></th>
<th align='center' style='border:dotted 1px;' bgcolor='#66CC00'><font color='#FFFFFF'><strong>Details</strong></font></th>
</tr>";
while($result = mysql_fetch_array($myData))
{
{
$status = $result['status'];
$status = str_replace("\r\n", "<br>", $status);
$status = str_replace("\r", "<br>", $status);
$status = str_replace("\n", "<br>", $status);
$task = $result['task'];
$task = str_replace("\r\n", "<br>", $task);
$task = str_replace("\r", "<br>", $task);
$task = str_replace("\n", "<br>", $task);
$owner = $result['owner'];
$owner = str_replace("\r\n", "<br>", $owner);
$owner = str_replace("\r", "<br>", $owner);
$owner = str_replace("\n", "<br>", $owner);
$date = $result['date'];
$date = str_replace("\r\n", "<br>", $date);
$date = str_replace("\r", "<br>", $date);
$date = str_replace("\n", "<br>", $date);
$details = $result['details'];
$details = str_replace("\r\n", "<br>", $details);
$details = str_replace("\r", "<br>", $details);
$details = str_replace("\n", "<br>", $details);
echo "<form action='get_test.php' method='post'>";
echo"<tr>";
echo "<td align='center'>" . $result['status'] . "<input type=hidden name=status value=" . $result['status'] . " </td>";
echo "<td align='center'>" . $result['task'] . "<input type=hidden name=task value=" . $result['task'] . " </td>";
echo "<td align='center'>" . $result['owner'] . "<input type=hidden name=owner value=" . $result['owner'] . " </td>";
echo
"<td align='left' width='auto'>
" . $date . "<input type=hidden name=date value=" . htmlspecialchars($date) . " /><br>
" . $details . "<input type=hidden name=details value=" . htmlspecialchars($details) . " /> </td>";
"</tr>";
echo "</form>";
}
}
echo "</table>";
感謝您的幫助,但即時得到這個錯誤: '警告:mysql_fetch_array()預計參數1是資源,布爾在C中給出:行\ XAMPP \ htdocs中\跟蹤\ get_test.php 64' – testyummy
這是一個不同的錯誤。最初,你不應該使用'mysql_ *'函數,因爲它們在PHP 7中被棄用和刪除。[''mysql_fetch_array'](http://php.net/manual/en/function.mysql-fetch-array.php)想把'mysql_query'的結果作爲它的第一個參數,但是你給它一個數組。 –
對不起,但我是新來的這種編碼的東西...任何想法如何解決上述我的代碼給出的錯誤? – testyummy