1

I need to be able to bring up a list of items from the database. That part I have done. But then I need to be able to have it so that the user can select the name of the item to go to a detail page. What I can't figure out is how to get the script to take the auction name and send that to another page. What I have to pull the info is below. Not looking for someone to do it for me, just need some help figuring out how to get there.

if (mysql_num_rows($result) > 0) 
{
    while ($row = mysql_fetch_array($result)) 
    {
        $aucname = $row['aucname'];
        $seller = $row['seller'];
        $price = $row['price'];
        $start = $row['start'];
        $end = $row['end'];
        $nbids = $row['nbids'];
        $category = $row['category'];

        $display_block = "Auction Name - $aucname      
                          Seller - $seller      
                          Price - $price      
                          Start Date - $start </br>
                          End Date - $end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                          # bids - $nbids &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                          Category - $category <p> ------------------ </p>";
    }
    echo "$display_block";
}
1
  • BTW, long-term, you will want to use some sort of [MVC] pattern. Commented Jun 14, 2011 at 21:52

3 Answers 3

2

Something like $link = "pagename.php?aucname=$aucname"; will send that variable via the url. You can also use a hidden form element to pass the data as a piece of the form. On the page you're passing to, this info will show up in either $_GET (for the URL iirc) or $_POST (when you pass the variable through a form that's using post).

Sign up to request clarification or add additional context in comments.

Comments

1

The common way of doing it is to add a unique id for each row, and pass it through a $_GET variable. See a skeleton example below:

if (isset($_GET['id'])) {
   /* detailed entry 'id' */
}
else {
   /* all the entries */
   while (...)
     $display_block = '<a href="yourpage.php?id='.$row['id'].'">Auction Name...</a>';
}

Comments

0

If you don't want the answer then your best bet would be to look up POST and GET. If you already can pull the information from the database then you could easily pass the object id or whatever you want to the details page and then pull the rest of the information from there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.