I have a table that has an attribute named URL
, when adding registries to this table,
I can choose to leave that field NULL
or to write a URL
. If I leave it empty, I want to shows the url autoassigned
that I created ($url)
.
If its not empty, I want to show the content of the registry (row URL
) right now, I did the first part... I don't know how to the second part.
$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_
functions as they are deprecated. Usemysqli_
instead :)