Subject: I'm sure there's a simple answer to this!
Posted By: Jams30 Post Date: 10/27/2003 12:53:57 PM
Hi

Firstly, please excuse my lack of understanding on PHP and MySql as I am but a struggling newbie with all of this!!

I have created a simple MySql database and am trying to retrieve records from it based on a query. I have built a form with two list boxes, 'From' and 'To' - when selecting an option from both lists and submitting the form, the information is getting passed to the next page where I can associate variables $From_Price and $To_Price respectively. As you can see, I have tested these variables in the first echo statement, but when trying to use them as part of a query statement I get nothing appearing on the page as results apart from the "Your selection of properties are..."

<?php
include "./common_db2.inc";

echo "
Your selection of properties are from $From_Price to $To_Price
<br><br>";
$link_id = db_connect();
$result = mysql_query("select * from prices WHERE price >= '$From_Price' and price <= '$To_Price' order by price", $link_id);

while($query_data = mysql_fetch_row($result)) {
echo "Property no: ",$query_data[0]," is priced at £",$query_data[1]," and the description on this is ",$query_data[2],"<P>";
}

?>


Whilst this query works fine with static values I want to the use to be able to choose the parameters that the query is based on.

Can someone please advise me on where I may be going wrong, as the title suggests, I'm sure there's a simple answer to this!!


Many thanks

Jamal


Go to topic 5731

Return to index page 1018
Return to index page 1017
Return to index page 1016
Return to index page 1015
Return to index page 1014
Return to index page 1013
Return to index page 1012
Return to index page 1011
Return to index page 1010
Return to index page 1009