Hi there,
I'm having a bit of a nightmare and was hoping for some help please 🙂
I currently have a simple form with list/menu and options that determine how records in a table are ordered by:
<form action="view_food.php" method="get" name="reorder" id="reorder">
<select name="orderby" onchange="if(this.value != '-') document.reorder.submit();">
<option "-">Select one...</option>
<option value="FoodID">ID</option>
<option value="FoodName">Name</option>
<option value="AnimalTypeID">Food Type</option>
<option value="Username">User</option>
</select>
</form>
<?php
$currentPage = $_SERVER["PHP_SELF"];
if (isset($_GET['orderby'])) {
$orderby= $_GET['orderby'];
}else{ $orderby="FoodID"; }
//CHECKING TO SEE IF THE PERSON HAS CHOSEN TO ORDER BY A CERTAIN FIELD
?>
This all works fine at present, but as i have continued with my project i have found the need to add a new option in the list/menu and relate that option to a WHERE clause in my query. This will allow me to find all records WHERE tablefield "CID"= 6 - which is a static number.
for example:
$test= ("SELECT * FROM foods WHERE CID = 6 ORDER BY $orderby ASC");
<option value="Where clause example">CID number</option>
Is it possible to add a WHERE clause to my existing query and present that as an option in the list/menu??
If anybody could please help me that would be great as i'm rather stuck.
Thank You 🙂