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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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