Jump to content

Link & Database


prospect

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

?>
Link to comment
https://forums.phpfreaks.com/topic/17575-link-database/
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]
Link to comment
https://forums.phpfreaks.com/topic/17575-link-database/#findComment-74881
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
Link to comment
https://forums.phpfreaks.com/topic/17575-link-database/#findComment-74882
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.
Link to comment
https://forums.phpfreaks.com/topic/17575-link-database/#findComment-74887
Share on other sites

Archived

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

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