Jump to content

Trying to build a DB driven menu for my site


VinceGledhill

Recommended Posts

Hi People.

 

I am running a site which is mainly built around PHP but am using a joomla front end and I'm getting sick of it.

 

This is because every time a new record is added to the DB I have to manually add a link to the menu to make the "airfield card" visible.

 

What I am trying to do is build a DB driven menu.

 

Here is my code for my connection to the DB

 

<?php

$host = 'localhost';
$usr = "theusername";
$password = 'thepassword';
$db_name = 'thedbname';

//connect to database
mysql_connect ("$host","$usr","$password") or die ('Error During Connect:<br>'.mysql_error());
mysql_select_db ("$db_name") or die ('Error Selecting DB:<br>'.mysql_error());
?>

 

Here is my code that is supposed to show me a list of "airfields" from the 'users' DB and dynamically list the 'username' table contents.

 

 <?php include("db_connect.php");
$users_sql = "SELECT * FROM users";
$users_query = mysql_fetch_assoc(users_sql) or die (mysql_error());
$rsUsers = mysql_fetch_assoc ($users_query);

?>

<h2>News</h2>
    <div class="scroll">
           
      <h3>31st July 2012</h3>
      <p class="news">New HTML site created which has made the whole job of adding new airfields that much easier.  As soon as you submit an airfield it becomes visible.
      
      </div>
<li><a href="add.php">Add New Airfield</a></li>
<h2>Airfields</h2>
<ul>
<li><a href="alpha.php">Alpha</a></li>

<ul>
<?php do {
?>
<li><a href=""><?php echo $rsUsers ['username']; ?>	</a></li>
<?php	
} while ($rsUsers = mysql_fetch_assoc ($users_query));
?>
</ul>

<li><a href="bravo.php">Bravo</a></li>

 

However, all I am getting is a blank area on the site which is in a temporary home here

http://www.airfieldcards.com/vg_temp/add.php

 

Please can someone look at my code and tell me where I'm going wrong.

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.