Jump to content

PHP/Mysql Page Nav and Display.


Drewdle

Recommended Posts

Hey,

 

I'm having problems displaying data from a mysql database properly.

 

Problem page: here

 

It's a bit like a cms, a user fills out a form asking for a page title and the page content, thats then stored in the database and the finished result should be the page title added to the navigation and when clicked displaying the relevant page.

 

I don't know if its possible but I'd like it to be done all on the one page.

 

As you can see on the link I provided, when you click more than one link it displays it on the same page, rather than replacing itself. Can you help with this?

 

Code:

<html>
<head>
<script>

function show_content(id){
    document.getElementById(id).style.display='block';
}


</script>
</head>
<body>
<font face=verdana size=1>
<?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</a> ";
    echo "<div id=\"$id\" style=\"display:none\">$content</div>";
}


?>
<hr>

</body>
</html>

 

Also, any idea how I should do the navigation? As you can see the more pages added the longer the navigation will get...eventually extending beyond the page width and creating problems.

 

I understand I have problems explaining, if you need more just let me know!

 

Thanks,

Drew.

 

Link to comment
https://forums.phpfreaks.com/topic/223640-phpmysql-page-nav-and-display/
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.