Help with getting info from my database using radio buttons
Posted: Mon Oct 13, 2008 8:23 am
Hi Have two drop down lists one that allows a user to select a country with the variable called $cat
The other drop down list allows a user to select a city from the country selected the variable for the city selected is $subcat.
What I have done next is display two radio buttons one that asks the user if it is a full load and one for half load. I have manged to get the value selcted from the radio button and display it, but cannot get the price displayed from my database for full load or half load.
the following is the code I have used but it just wont display the price
The following is all the code for the page
Hope someone can advise
I know I can get the value as I do the following at it displays correctly
but when I try the mysql query it does not do anything
The other drop down list allows a user to select a city from the country selected the variable for the city selected is $subcat.
What I have done next is display two radio buttons one that asks the user if it is a full load and one for half load. I have manged to get the value selcted from the radio button and display it, but cannot get the price displayed from my database for full load or half load.
the following is the code I have used but it just wont display the price
Code: Select all
if ($load =='full_load'){
$price=mysql_query("SELECT DISTINCT full_price from eu_place where city=$subcat"); }
else {$price=mysql_query("SELECT DISTINCT half_price from eu_place where city=$subcat"); }
echo "Value of \$price = $price";The following is all the code for the page
Code: Select all
<?php
include 'dd.php';
?>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Demo Multiple drop down list box from plus2net</title>
</head>
<body>
<?php
$cat=$_POST['cat'];
$subcat=$_POST['subcat'];
$load=$_POST['load'];
echo "Value of \$cat = $cat <br>Value of \$subcat = $subcat"."<BR>";
echo "Value of \$load = $load";
if ($load =='full_load'){
$price=mysql_query("SELECT DISTINCT full_price from eu_place where city=$subcat"); }
else {$price=mysql_query("SELECT DISTINCT half_price from eu_place where city=$subcat"); }
echo "Value of \$price = $price";
?>
</body>
</html>
Hope someone can advise
I know I can get the value as I do the following at it displays correctly
Code: Select all
if ($load =='full_load')
{
$price='hi'; }
else {$price= 'bye'; }
echo "Value of \$price = $price";