PHP/Mysql Page and Nav...

I’m new to php and I’ve decided the best way to learn is by doing…so I’ve decided to create a CMS, you may think thats quite a big project for a first timer but its actually working quite well except for the odd bit.

One of those odd bits is this…

I have a form that enters information into a database (page title and page content), the trouble I have is trying to display it correctly. Using the code below I can get it to display:
[php]

<?php include 'dbwire.php';

$query = mysql_query(‘SELECT * FROM content’);

while($results = mysql_fetch_array($query,MYSQL_ASSOC)){
$title = $results[‘title’];
$id = $results[‘id’];
$content = $results[‘content’];
echo “| <a href=“javascript:void(0);” onclick=“show_content($id)”>$title “;
echo “<div id=”$id” style=“display:none”>$content”;
}

?>


[/php]

Now the problem with this, as you can see here: http://chillpot.co.uk/php/content2.php is that when you click a link it shows the correct page, then when you click a different link it shows that page aswell as the previous one.

Is there a way to replace the displayed page with the next clicked link instead of all of them?

Cheers.

Have a look here, I guess this is what you are trying to do:)

http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

Sponsor our Newsletter | Privacy Policy | Terms of Service