Hello everyone. :)
I am attempting to construct a query with PHP and MySQL based on user input from a
referring form page. Here is an example of what I need this to do:
This will involve multiple variables, but I will just use 2 here:
if ($dig== "1") {
$qual1 = "WHERE (track >= 0)";
}
if ($dig== "2") {
$qual1 = "WHERE (track >= 0) AND (track <=100)";
}
if ($lot == "1") {
$qual2 = "AND (acres >= 100)";
}
if ($lot == "2") {
$qual2 = "AND (acres >= 500) AND (acres <= 650)";
}
// create SQL statement
$sql = "SELECT * FROM myTable $qual1 $qual2";
// execute SQL query and get result
$sql_result = mysql_query($sql,$connection)
or die("Could not execute the query");
.....
You can see my problem here. I want to be able to write parts of my sql statement
based upon user input, and then execute it all at once. How do I tie all of my $qual
variables in so that this will read/execute it properly?
Thanks :)
[PHP] PHP and MySQL ....dynamic query?
Blueriver Networking Services Mon, 05 Mar 2001 14:16:51 -0800
- Re: [PHP] PHP and MySQL ....dynamic query? Blueriver Networking Services
- Re: [PHP] PHP and MySQL ....dynamic que... Richard Lynch

