I want to create a dynamic footer menu (not multilevel) with mysql.
My MySQL table is like below...
---------------------------------------------------
| menu_id | menu_name | menu_url | short_id |
----------------------------------------------------
| 1 | Home | index.php | 1 |
----------------------------------------------------
| 2 | Contact Us | contact.php| 3 |
----------------------------------------------------
| 3 | About Us | abt.php | 2 |
----------------------------------------------------
The HTML structure is like...
<div class="footer-menu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="abt.php">About Us</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>
</div>
I have coded like...
mysql_select_db($db,$con);
$f_menu_qry = "SELECT * FROM footermenu ORDER BY short_id ASC";
$fm = mysql_query($f_menu_qry,$con);
$f_menu = mysql_fetch_assoc($fm);
$totrows = mysql_num_rows($fm);
$menu_name = $f_menu['menu_name'];
$menu_url = $f_menu['menu_url'];
public function getFooterMenu(){
global $fm, $f_menu, $menu_name, $menu_url, $totrows;
$footer_menu = '';
$cnt = 0;
while ($clt_f_menu = mysql_fetch_assoc($fm)){
$cnt++;
$footer_menu = '<li><a href="'.$menu_url.'">'.$menu_name.'</a></li>';
if($cnt == $totrows){
return;
}
}
echo $footer_menu;
}
The output should be like Home / About Us / Contact Us
But the output is showing only Home.
I have tried different processes but those were showing errors(may be for my faulty code) but this time it is showing at least a link.
I am unable to do it.
What should I do ?