什麼是「回聲」生成的HTML代碼的最佳做法?我必須通過循環顯示一組數據。在這種情況下,html代碼必須在函數apply_task()中生成。代碼完成後,它將跳回到index.html。如果$ count = 0,則顯示「生成的html代碼」。PHP在哪裏把生成的HTML代碼
它工作正常,但調試它很煩人。我必須從index.html跳轉到function.php文件,看看會發生什麼,然後跳回到index.html來跟蹤代碼。我發現這很累!
你們有同樣的問題嗎?如果沒有,你會怎麼做更好的結構?
的index.html
<?php
$count = check_user($link, $taskid, $taskerid);
If ($count == 0){
apply_task($link, $taskid);
}else{
echo "you can't add yourself to your own work";
echo "<br>";
};
?>
function.php
function apply_task($link, $task_id){//change name
//echo $session[$id] = $id;
$sql = "select * from wuuk where id = '$task_id';";
$result = mysql_query($sql, $link);
$row = mysql_fetch_array($result, MYSQL_NUM);
echo "<br>";
echo "<h1>Workk information:</h1>";
echo "<table class='apply_table'>";
echo "<tr class='blank_row'><td colspan='2'></td></tr>";
echo "<tr><td>Name:</td><td>$row[2]</td></tr>";
echo "<tr><td>Price:</td><td>$row[4]</td></tr>";
echo "</table>";
echo "<br>";
};
或者只是將其字符串化,然後回顯 –