Jump to content

How to create a static html menu from a database


dhope

Recommended Posts

Hi,

 

I have built a small cms which allows me to create simple html pages and then upload them to an ftp.

 

Everything is working apart from the menu, I cant get my head round how to create the menu system. The outputted file is a static html file that wont be connected to a database, so I need to retrieve the information from the database then write this information in standard html to a page before it is sent to the ftp.

 

I have looked through the forum and the net and can't find a solution, can anyone help?

 

CODE//// (which I know is incorrect, but kind of works and should hopefully show what I mean)

 

$page_name = mysql_query("SELECT * FROM pages WHERE page_display = 'yes' ORDER BY page_order ASC")

or die(mysql_error());

 

 

while($info = mysql_fetch_array( $page_name ))

{

$page[] = $info[page_name];

}

 

$navigation = <<<EOD

 

 

<li>$page[0]</li>

<li>$page[1]</li>

<li>$page[2]</li>

<li>$page[3]</li>

 

 

EOD;

maybe this will help more unless you only want 4 menu items

echo "<ul>";
while($info = mysql_fetch_array( $page_name ))
{
$page = $info[page_name];

echo "<li><a href='".$page.".html'>$page</a></li>";

}
echo "</ul>";

 

 

I'm not sure if I understand what you are trying to achieve. So, you want your CMS to be a generator for static HTML pages? Does your script run on the same server as your "real" homepage is running? If yes, you can simply save the file with PHP's file handling functions. (fopen etc)

If not, you can use the FTP functions:

http://ch2.php.net/manual/en/book.ftp.php

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.