Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 27th, 2001, 01:25 PM
duckisme duckisme is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Pittsburgh, PA
Posts: 24 duckisme User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy passing a $variable; then calling it's row from database

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?

Reply With Quote
  #2  
Old July 28th, 2001, 07:16 AM
Pressly Pressly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 48 Pressly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Lightbulb For Starters

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.

Reply With Quote
  #3  
Old July 28th, 2001, 07:57 AM
duckisme duckisme is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Pittsburgh, PA
Posts: 24 duckisme User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old July 28th, 2001, 09:57 AM
duckisme duckisme is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Pittsburgh, PA
Posts: 24 duckisme User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile figured it out

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);

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > passing a $variable; then calling it's row from database


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway