Re: query selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> the first list that is displayed has an ID for each product.  But when I
> click on it, it goes to the next page but does not display the rest of the
> products that are listed in the second table.
>
> $query = "SELECT  * FROM product_list  WHERE productid = id";
>
> Id being the description ID that came off the first page.

Well, 'id' should at least be a variable, right? I assume your links look
something like this:

http://www.yourdomain.com/page.php?id=X

where X is the 'id' number you want to pass to the above select statement.
If so, then you'd use:

$query = "SELECT * FROM product_list WHERE productid = {$_GET['id']}";
or
$query = "SELECT * FROM product_list WHERE productid = " . $_GET['id'];

where $_GET['id'] is a variable containing the value passed in the URL. Make
sure you properly validate $_GET['id'] to make sure it's a valid ID (or at
least an integer) before you stick it in your SQL statement, also.

$id = (int)$_GET['id'];
$query = "SELECT * FROM product_list WHERE productid = $id";

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux