Filtering Combobox PHP+MSSQL Problem
Posted: Mon Apr 17, 2006 7:19 am
Helo, this is my first post........im a total n00b and im self taught and im having this realy niggly problem......hope someone should point out the obvoius that im not seeing
firsly il post the code and error msg in im keep getting when trying to display records based on a combobox selection from a previous page: -
heres the code that (theoretically) should retun all equipment details based on the location selected on the previous page-
there alot more code than this but the error msg is in regards to the WHERE Location = ".$_POST["cmbLocation"].""; bit
this is the eror msg i keep getting
can anyone see what im doing wrong cos ive done the identical thing on another section and it works just dandy.
any/all advice is appreciated and thank you in advance
firsly il post the code and error msg in im keep getting when trying to display records based on a combobox selection from a previous page: -
heres the code that (theoretically) should retun all equipment details based on the location selected on the previous page-
Code: Select all
if(array_key_exists("cmdSearch", $_POST) )
{
open_db();
$query = "SELECT Equipment, Description, Location, Area, Bookable FROM Equipment WHERE Location = ".$_POST["cmbLocation"]."";
$result = mssql_query($query) or die ("error in connection");this is the eror msg i keep getting
here the code for the combobox on the previous page - cmbLocationWarning: mssql_query(): message: Line 1: Incorrect syntax near '='. (severity 15) in d:\inetpub\wwwroot\admin\manageequipment.php on line 54
Warning: mssql_query(): Query failed in d:\inetpub\wwwroot\admin\manageequipment.php on line 54
error in connection
Code: Select all
<select name="cmbLocation" id="cmbLocation">
<?php
open_db();
$query = "SELECT COUNT (Equip_ID), Location FROM Equipment GROUP BY Location ORDER BY Location ASC";
$result = mssql_query($query) or die ("error in connection");
while($Equipment = mssql_fetch_assoc($result))
{
echo("<option value=".$Equipment["Equip_ID"].">".$Equipment["Location"]."</option>");
}
mssql_close();
?>
</select>any/all advice is appreciated and thank you in advance