im making something like news page or blog and i want to create dynamical menu. im newbie in databases, but i started to make it. ill show what i have done and i would like to hear your advices what to improve in my code.
this is my table called categories:
http://img68.imageshack.us/img68/2166/cattyp6ah.jpg
this is content of it:
http://img66.imageshack.us/img66/9677/categories4wn.jpg
if type is not 0 then category is subcategory..
field under allocates subcategory to main category
and field orderr shows in what order categories will be showed
and this script:
<?
$SQL = "SELECT * FROM categories ORDER BY type, orderr;";
$result = @mysql_query( $SQL );
while( $row = @mysql_fetch_array( $result ) ) {
if ($row[type]=='0'){
echo "<b>$row[name]</b><br>";
$ssql = "SELECT * FROM categories WHERE under=$row[id] ORDER BY orderr;";
$rresult = @mysql_query( $ssql );
while( $rrow = @mysql_fetch_array( $rresult ) ) {
echo "$rrow[name]<br>";
}
}
}
?>
.. it make my menu look thisway:
news
...from USA
...celebrities
gallery
...easters
...santa claus..
web-doc
...mysql
...php
...perl
i hope that someone will know how to improve this script, because i have small expierence in working with databases.