|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I have built a dropdown menu pulling all the info found under the "product" column from my table, myproducts ( I am using MySQL for database).
"On change", I am posting the form, which passes the variable $product to another .php page. This is successful as my new .php page is recognizing that the variable $product = "Cool Product" ("Cool Product" being the line chosen in dropdown menu). I used echo "$product"; to test that the variable is there and has a value of "Cool Product" My problem is: How do I query all the other information associated with just that product and only that product? ie: how do I call up the row for the selected variable $product? |
|
#2
|
|||
|
|||
|
Do a query on the database seeking that product only:
select * from PRODUCTS where NAME='Cool Product' Put your actual table name in place of PRODUCTS and your actual column name in place of NAME. |
|
#3
|
|||
|
|||
|
I will know know if it is "Cool Product" or "Another Cool Product"
I will not know the actual name of the product. (ie: "Cool Product") The dropdown menu was populated automatically from database using php script.
I have named the drop down menu on the first page "product" which passes the variable $product (and it's value) to next page. That said, should I write: select * from PRODUCTS where NAME='$product' I think I have tried that, but maybe my syntax is wrong. |
|
#4
|
|||
|
|||
|
thanks for your help.
this is what produced the results I needed on my second page. I passed my $product_id instead of $product. Not sure if that is what made the difference: $result = mysql_query("SELECT * FROM products WHERE product_id='$product_id'") or exit; if ($myrow = mysql_fetch_array($result)); { do { printf("<tr><td>%s</td><td>%s</td></tr>\n", $myrow["product_id"], $myrow["product"]); } while ($myrow = mysql_fetch_array($result)); echo "</table>\n"; mysql_free_result($result); |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > passing a $variable; then calling it's row from database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|