Jump to content

Recommended Posts

Hi,

 

I tried writing some code for my navigation menu to make it easier on my part (with creating the site etc).

 

I have written this so far:

 


<?php

$nav = select("*", "navigation", NULL, NULL, NULL);
$num = mysql_num_rows($nav);
$get = mysql_fetch_assoc($nav);
$filename = file_exists($_SERVER["DOCUMENT_ROOT"]."forum/".$get["file_path"]);

if($num > 0){
while($get = mysql_fetch_assoc($nav)){
if($filename){

$path = $GLOBALS["siteUrl"].$get["file_path"];



echo '<li><a href="'.$path.'">'.$get["page_name"].'</a></li>';
}
}
}else{
echo "<li>Could not find a navigation menu.</li>";
}

?>

 

Problem is, even though there is an entry in the database (to a page that DOES exist) nothing shows in the navigation area, can't think why.

 

Any help would be appreciated.

Link to comment
https://forums.phpfreaks.com/topic/269071-coding-problem-for-navigation/
Share on other sites

I ehcoed $filename, the path(s) were correct,

 

$num echos "1" which is correct due to there only being 1 row in the database, if i use a while and echo $get["file_path"] and $get["page_name], they are also correct... no errors show on the screen.

Your code makes no logical sense. You are fetching the first row from the result set before the start of the while loop. If there's only one row, the while loop will be skipped over and if there is more than one row, the first one won't be present inside of the while loop.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.