Jump to content

Dynamic Navigation


kr9091

Recommended Posts

<?php 
$fp = fopen('flat-file-data.txt','r'); 
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;} 
  
while (!feof($fp)) { 
$line = fgets($fp, 1024); //use 2048 if very long lines 
list ($field1, $field2, $field3, $field4, $field5, $field6) = split ('\,', $line); 
echo ' 
<tr> 
<td>'.$field1.'</td> 
<td>'.$field2.'</td> 
<td>'.$field3.'</td> 
<td>'.$field4.'</td> 
<td>'.$field5.'</td> 
<td>'.$field6.'</td> 
</tr>'; 
$fp++; 
} 
  
fclose($fp); 
  
?> 

 

Link to comment
https://forums.phpfreaks.com/topic/81777-dynamic-navigation/#findComment-415455
Share on other sites

<?php 
$fp = fopen('flat-file-data.txt','r'); 
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;} 
  
while (!feof($fp)) { 
$line = fgets($fp, 1024); //use 2048 if very long lines 
list ($field1, $field2, $field3, $field4, $field5, $field6) = split ('\,', $line); 
echo ' 
<tr> 
<td>'.$field1.'</td> 
<td>'.$field2.'</td> 
<td>'.$field3.'</td> 
<td>'.$field4.'</td> 
<td>'.$field5.'</td> 
<td>'.$field6.'</td> 
</tr>'; 
$fp++; 
} 
  
fclose($fp); 
  
?> 

 

 

 

Thanks for your quick reply. I tried the code you supplied and subbed in information where necessary. However, I am still having trouble displaying this properly. Perhaps I was a little too unclear of what I am trying to accomplish. Or perhaps I am not using the code provided, correctly. Let me try again:

 

The website has a navigation bar on either the top or the left side. This choice is dynamically controlled. The navigation bar consists of a home button plus three other choices. These 4 links are image links, not text links.

 

There is a configuration file on the server called "navigation.txt" It contains one record with the navigation location, plus several more for each active/inactive navigation choice:

 

TOP

ACTIVE,ABOUT.PHP,ABOUT.GIF,1

ACTIVE,RES.PHP,RESOURCES.GIF,3

ACTIVE,CLASSES.PHP,CLASS.GIF,2

INACTIVE,CTE.PHP,CTE.GIF,4

 

Each page starts with an include statement, which contains a function called do_navigation() This function should dynamically generate the navigation bar based on the contents of the navigation.txt

 

Do_navigation uses file functions to open and read navigation.txt It saves the value of record 1, which controls whether the navbar is on the side or the top. It should also only load the active navigation data into a 3-dimensional array and sort the array by sequence number. It also generates the HTML which lays out the "home" button plus three dynamic choices which then passes this back to the calling program as a string.

Link to comment
https://forums.phpfreaks.com/topic/81777-dynamic-navigation/#findComment-415486
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.