0
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{    
echo "<tr>";
echo "<td><p>{$row['tittel']}</p></td>";
echo "</tr>";
echo "<tr>";
echo "<td><textarea rows='1' cols='64' style='no-resize;'>{$row['video']}</textarea></td>"; 
echo "<td><form method='GET' action='delete.php'>";
echo "<input type='hidden' name='delete_id' value='{$row['id']}'/>"; 
echo "<input type='submit' name='submit' value='Delete' style='margin-bottom: 30px;'>";
echo "</form></td>";    
echo "</tr>";
} 

这可能是基本的东西,但我仍在学习。

先感谢您!

4

2 回答 2

2

mysql_num_rows()

if(mysql_num_rows($retval)){
    while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
        {  ...  } 
} else {
    echo 'no rows';
}

PS: php_mysql扩展名已弃用。我建议使用php_mysqliorphp_pdo代替。

于 2013-04-26T08:49:39.073 回答
1
if(mysql_num_rows($retval) != 0) {
   while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) {    
       echo "<tr>";
       echo "<td><p>{$row['tittel']}</p></td>";
       echo "</tr>";
       echo "<tr>";
       echo "<td><textarea rows='1' cols='64' style='no-resize;'>{$row['video']}</textarea></td>"; 
       echo "<td><form method='GET' action='delete.php'>";
       echo "<input type='hidden' name='delete_id' value='{$row['id']}'/>"; 
       echo "<input type='submit' name='submit' value='Delete' style='margin-bottom: 30px;'>";
       echo "</form></td>";    
       echo "</tr>";
    }
 } else {
    //Your message here
 }
于 2013-04-26T08:50:40.893 回答