prospect Posted August 15, 2006 Share Posted August 15, 2006 Hey guys , I am working on a news script, i did my table and i extract the news and display them and i even made the pagination and everything but i am trying to make a topic list using $title as variable, so far i been able to display all the titles but i want to be able to click on them and that takes me to the relevant specific topic please help...this is what I tried so far<?include "*****.php";$headers = mysql_query("select id, title from news ");while( $row = mysql_fetch_array($headers) ){ echo " <div><p style=\"padding:0;margin:3px 0;\"> <b><a href=?id=$row[id]> ". $row[title] ."</a></b><br /></p> </div>\n"; }?> Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Does it give you an error, or just not work, or what? Try:[code]<?include "*****.php";$headers = mysql_query("select id, title from news ");while( $row = mysql_fetch_array($headers) ){ echo " <div><p style=\"padding:0;margin:3px 0;\"> <a href=http://www.domain/page.php?id=$row[id]> ". $row[title] ."[/url]</p> </div>\n"; }?>[/code] Quote Link to comment Share on other sites More sharing options...
prospect Posted August 15, 2006 Author Share Posted August 15, 2006 nah it doesn't give me any error but when i click on the titles it doesn't take me to the relvant topic its just reloads the page and change the url to www.domain.com/blah.php?id=2 or 3 or 1 depending on what i clicked on so it is working but it displays the same page with all the headers again doesn't display the topic Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 Do you have the page setup to display the relevant information depending on the id? Quote Link to comment Share on other sites More sharing options...
prospect Posted August 15, 2006 Author Share Posted August 15, 2006 umh okai I am a student so take it easy on me, I though the page will be generated on the fly, do i have to create a indivdual page for each and every result? cause that will just defy the purpose of the database..ps; thanks ALOT for the help :) Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 15, 2006 Share Posted August 15, 2006 No, you need to create the page to select the results from of the database and display them. The id is the unique identifier to tell the database what row it needs to select the information from. So for example you could make a page that selects the results " WHERE id = '$id' " . Then make the rest of the page to contain the results. Then the information selected would depend on what the id is. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.