我有一個表的屬性名爲URL
,在向此表添加註冊表時,我可以選擇離開該字段NULL
或編寫URL
。如果我將它留空,我想顯示我創建的網址autoassigned
($url)
。 如果它不是空的,我想現在顯示註冊表(row URL
)的內容,我做了第一部分......我不知道如何做第二部分。php和mysql的問題
$sql="select * from agenda";
$result= mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result)==0) die("No hay registros para mostrar");
echo "<table border=1 cellpadding=4 cellspacing=0>";
echo "<tr>
<th colspan=5> Agenda </th><tr>
<th> Categoria </th><th> Evento </th><th> Fecha </th><th> Hora </th><th> Info </th><th> ID </th>";
while($row=mysql_fetch_array($result))
{
$url= $row[id].".php";
echo "<tr>
<td align='left'> $row[categoria] </td>
<td> <a href= '$url'> $row[evento] </a> </td>
<td> $row[fecha] </td>
<td> $row[hora] </td>
<td> $row[info] </td>
<td> $row[id] </td>
</tr>";
}
較短的版本,因爲他們已被棄用,則不應使用'mysql_'功能。使用'mysqli_'代替:) – 2013-03-27 16:17:33