Jump to content

Archived

This topic is now archived and is closed to further replies.

prospect

Link & Database

Recommended Posts

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

?>

Share this post


Link to post
Share on other sites
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]

Share this post


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

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.