Jump to content


Photo

Link & Database


  • Please log in to reply
5 replies to this topic

#1 prospect

prospect
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 15 August 2006 - 02:00 AM

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";
}

?>

#2 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 02:19 AM

Does it give you an error, or just not work, or what? Try:

<?

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";
   }

?>


#3 prospect

prospect
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 15 August 2006 - 02:22 AM

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

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 02:33 AM

Do you have the page setup to display the relevant information depending on the id?

#5 prospect

prospect
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 15 August 2006 - 02:35 AM

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 :)

#6 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 15 August 2006 - 02:53 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users