RE: [PHP-DB] Another dynamic sql.
Seems like it will NOT work because you are selecting $car which is already chosen by the user (i.e. which is a known value). I don't know how you laid out your table but shouldn't your query be something like SELECT price from FROM varetabell where carid=$car ?? Gurhan -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Friday, January 25, 2002 1:48 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Another dynamic sql. Hi all! I have this form with some choices: form Enter how many cars you want:input type=text name=number select size=1 name=car option selectedford/option optionbmw/option optionmercedes/option /select And then I am trying to get the price out of a table in my database with this code: $sql = mysql_query(SELECT '$car' FROM varetabell where carid='$carid' ); $myrow= mysql_fetch_array($sql); $x = $myrow[$car]; $price = $x * $number; Shouldn't this work? Or am I missing something here? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Another dynamic sql.
My example was a litle confusing here I see. My table have multiple price columns. something like this: carid convertible stationvagon etc. etc 1100100100 - Original Message - From: Gurhan Ozen [EMAIL PROTECTED] To: Raymond Lilleodegard [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, January 25, 2002 8:11 PM Subject: RE: [PHP-DB] Another dynamic sql. Seems like it will NOT work because you are selecting $car which is already chosen by the user (i.e. which is a known value). I don't know how you laid out your table but shouldn't your query be something like SELECT price from FROM varetabell where carid=$car ?? Gurhan -Original Message- From: Raymond Lilleodegard [mailto:[EMAIL PROTECTED]] Sent: Friday, January 25, 2002 1:48 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Another dynamic sql. Hi all! I have this form with some choices: form Enter how many cars you want:input type=text name=number select size=1 name=car option selectedford/option optionbmw/option optionmercedes/option /select And then I am trying to get the price out of a table in my database with this code: $sql = mysql_query(SELECT '$car' FROM varetabell where carid='$carid' ); $myrow= mysql_fetch_array($sql); $x = $myrow[$car]; $price = $x * $number; Shouldn't this work? Or am I missing something here? Best regards Raymond -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Another dynamic sql.
Raymond, What sort of error are you getting? One of the most useful tools in your toolbox is the print() function. Try doing something like this: $sSQL = SELECT '$car' FROM varetabell WHERE carid='$carid'; print ($sSQL); $sql = mysql_query($sSQL); $myrow = mysql_fetch_array($sql); $x = $myrow[$car]; This will let you see exactly what query is being passed to the database, and that alone will frequently tell you where the problem lies. That is probably the best place to start. FWIW, in almost all of my database interactions, I set the query as a separate string variable, just so that I can use this sort of debugging technique. Raymond Lilleodegard wrote: Hi all! I have this form with some choices: form Enter how many cars you want:input type=text name=number select size=1 name=car option selectedford/option optionbmw/option optionmercedes/option /select And then I am trying to get the price out of a table in my database with this code: $sql = mysql_query(SELECT '$car' FROM varetabell where carid='$carid' ); $myrow= mysql_fetch_array($sql); $x = $myrow[$car]; $price = $x * $number; Shouldn't this work? Or am I missing something here? Best regards Raymond -- Sliante, Richard S. Crawford mailto:[EMAIL PROTECTED] http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford MSN: [EMAIL PROTECTED] It is only with the heart that we see rightly; what is essential is invisible to the eye. --Antoine de Saint Exupery Push the button, Max! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]