Forum Moderators: coopster
I've been banging my head off the wall trying to solve this problem for 3 days now.
I'm trying to create a navigation menu system, using two arrays (different columns within one mysql table) to represent each link and the corresponding link text.
I was hoping it would iterate through both columns, but it only seems to loop correctly on the second while statement.
here's the code...
// Print menu
echo "<table>\n";
while ($linkline = mysql_fetch_array($menulinks, MYSQL_ASSOC))
while ($textline = mysql_fetch_array($menutext, MYSQL_ASSOC))
foreach ($linkline as $links_menu) {
foreach ($textline as $links_text)
echo "\t\t<td class=$xostyle><a href=$links_menu>$links_text</a></td>\n";
echo "\t</tr>\n";
}
Any suggestions are appreciated, thank you.
Lets back up here. You only need one sql query. It should look something line "SELECT menu, text FROM yourtablename". Once you got that you just need one loop.
while ($row = mysql_fetch_assoc($result)) {
$links_menu = $row['menu'];
$links_text = $row['text'];
echo "\t\t<td class=$xostyle><a href=$links_menu>$links_text</a></td>\n";
echo "\t</tr>\n";
}
Something like that.
Tim