I have the following code and I want to retrieve the latest data from mysql and have it inside a table I have created. Could anyone tell me what's wrong with it?
Thank you in advance for your effort.
<td>Category Name :
</td>
<td><?php
$query= "SELECT * FROM categories;
$result = mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
if ($num>1) {
$to=1;
}else{
$to=$num;
}
$i=0;
while($i<$to){
$categoryname=mysql_result($result,$i,categoryname );
$i++;
}
?></td>
</tr>