Hay guys
I get a parse error when trying to browse multiple categories.
How it works is this:
On the search page w/form, there are four drop-down boxes that contain all records of different columns from my database. I wanted to engineer it so that, if the user only picked a selection from one drop-down box, the resulting query would pick it up and only display records from the categories they chose from. So if I choose 2/4 drop down boxes, then the query would only grab from those two columns.
At the top of each drop-down box is an <.option> tag, with value=0, like so:
Code:
<option value="0"></option>
This leaves the very top spot blank.
On my results page, I have it setup so it first checks if there are all value=0's passed to it, in which case it performs the broadest query possible for the table. If not, it runs through each drop down's value and adds the appropriate SQL query onto the final query. However, I am getting a parse error, as shown below:
PHP Code:
$sql_conn=mysql_connect($Host, $User, $Pass) or die("MySQL Error #".mysql_errno().": ".mysql_error());
$sql_db=mysql_select_db($DB);
if($_POST['p_Site_search']=="0" AND $_POST['p_Project_search']=="0" AND $_POST['s_Type_search']=="0" AND $_POST['s_Iteration_search']=="0") {
$SQL="SELECT COUNT(*) AS Total FROM ".$Table
// error, line 12
// Parse error: parse error, unexpected '}' in c:\program files\apache group\apache\htdocs\intranet_test\browseresults.ph p on line 12
} // line12 here
else {
$SQL="SELECT COUNT(*) AS Total FROM ".$Table." WHERE ";
if($_POST['p_Site_search']!="0"){
$SQL.=" p_Site='".$_POST['p_Site_search']."' AND ";
}
if($_POST['p_Project_search']!="0"){
$SQL.=" p_Project='%".$_POST['p_Project_search']."%' AND ";
}
if($_POST['s_Type_search']!="0"){
$SQL.=" s_Type='".$_POST['s_Type_search']."' AND ";
}
if($_POST['s_Iteration_search']!="0"){
$SQL.=" s_Iteration='".$_POST['s_Iteration_search']."' AND ";
}
}
$SQL.=" s_Iteration <> '0' ORDER BY p_Site DESC"; // i have no idea what this line is for
$SQL_Result=mysql_query($SQL, $sql_conn);
$SQL_Result_Array=mysql_fetch_array($SQL_Result);
$Total = mysql_count($SQL_Result);
From there, the code sets up to start printing the results all nice and pretty and goes on to perform pagination.
Anyways, can you guys figure out why it's telling me the closing brace is unexpected? I can't see why it is, and I've tried putting it in different spots, deleting it, everything i can think of.
Thanks!