right, firstly go here
www.caldicot-pc-helpdesk.co.uk/fcv/database/index4.php
what i am trying to achieve is in the search, you type in a string, if DVD or VIDEO table is selected from the dropdown box, i want it to execute some code which will display a certain number of fields.
else
if the PS2 OR xbox360 table is selected, i want it to execute another piece of code, reason being is because the video/dvd table have different fields from the XBOX & PS2 table..
i have achieved this with the following code
only problem is, when i choose xbox table or ps2 table, the only error it gives me is
Unknown column 'catagory' in 'where clause'
somewhere along the line the else if statement is picking up something from the 1st if statement, there is no field called "catagory" in my console games table.
www.caldicot-pc-helpdesk.co.uk/fcv/database/index4.php
what i am trying to achieve is in the search, you type in a string, if DVD or VIDEO table is selected from the dropdown box, i want it to execute some code which will display a certain number of fields.
else
if the PS2 OR xbox360 table is selected, i want it to execute another piece of code, reason being is because the video/dvd table have different fields from the XBOX & PS2 table..
i have achieved this with the following code
Code:
$input = strip_tags($_POST['userQuery']);
$searchTable = $_POST['select'];
if ($searchTable == DVD || VIDEO) {
$sql = "SELECT * FROM $searchTable WHERE MATCH (catagory, title, certificate) AGAINST ('$userQuery')";
$result = mysql_query($sql) or die (mysql_error());
//Shows number of rows (number of results)
///////////////////////////////////////
$num_rows = mysql_num_rows($result);
echo "Showing results\n: $num_rows of $num_rows ";
///////////////////////////////////////
//end of showing number of results code
while ($field = mysql_fetch_array($result))
{
echo '<div align="left" class="result">';
$searchResults = $field['catagory'];
echo '<b>Catagory: </b>';
echo $searchResults;
echo '<br>';
$searchResults = $field['title'];
echo '<b>Title: </b>';
echo $searchResults;
echo '<br>';
$searchResults = $field['certificate'];
echo '<b>Certificate: </b>';
echo $searchResults;
echo '<br>';
$searchResults = $field['price'];
echo '<b>Price: </b>';
echo $searchResults;
echo '<br>';
//IMAGE CODE//
echo '<img src='.$field['image']. '>';
echo "</div>";
}
}
elseif ($searchTable == "xbox360" || "ps2") {
$sql = "SELECT * FROM $searchTable WHERE MATCH (platform, developer, title, genre) AGAINST ('$userQuery)";
$result = mysql_query($sql) or die (mysql_error());
//Shows number of rows (number of results)
///////////////////////////////////////
$num_rows = mysql_num_rows($result);
echo "Showing results\n: $num_rows of $num_rows ";
///////////////////////////////////////
//end of showing number of results code
while ($field = mysql_fetch_array($result))
{
echo '<div align="left" class="result">';
$searchResults = $field['platform'];
echo '<b>Platform: </b>';
echo $searchResults;
echo '<br>';
$searchResults = $field['developer'];
echo '<b>Developer: </b>';
echo $searchResults;
echo '<br>';
$searchResults = $field['title'];
echo '<b>Title: </b>';
echo $searchResults;
echo '<br>';
$searchResults = $field['genre'];
echo '<b>Genre: </b>';
echo $searchResults;
echo '<br>';
$searchResults = $field['synopsis'];
echo '<b>Synopsis: </b>';
echo $searchResults;
echo '<br>';
$searchResults = $field['price'];
echo '<b>Price: </b>';
echo $searchResults;
echo '<br>';
//IMAGE CODE//
echo '<img src='.$field['image']. '>';
echo "</div>";
}
}
only problem is, when i choose xbox table or ps2 table, the only error it gives me is
Unknown column 'catagory' in 'where clause'
somewhere along the line the else if statement is picking up something from the 1st if statement, there is no field called "catagory" in my console games table.