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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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