Drewdle Posted January 7, 2011 Share Posted January 7, 2011 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 More sharing options...
Gighalen Posted January 7, 2011 Share Posted January 7, 2011 Have you considered using Ajax? Link to comment https://forums.phpfreaks.com/topic/223640-phpmysql-page-nav-and-display/#findComment-1156058 Share on other sites More sharing options...
Drewdle Posted January 7, 2011 Author Share Posted January 7, 2011 I did notice whilst looking for help most results used Ajax, however I am only just learning php, I would have no idea what to do with Ajax, I'm not even sure what it is? Link to comment https://forums.phpfreaks.com/topic/223640-phpmysql-page-nav-and-display/#findComment-1156064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.