Here is my PHP code:
$fields=array('eventID','eventTitle','te_events.venueID','te_events.catID ',
'eventStartDate','eventEndDate','eventPrice');
// initialize empty array for WHERE clauses
$wheres=array();
// loop through field names, get POSTed values,
// and build array of WHERE clauses, excluding false values
foreach ($fields as $field) {
// get existing field value from POST, mark missing or empty value as FALSE
${$field} = isset($_POST[$field]) && trim($_POST[$field])!=''
? trim($_POST[$field]) : false;
// add to array of WHERE clauses only if value is not FALSE
if (${$field}) { $wheres[]="$field='".${$field}."'"; }
}
// build SELECT statement from WHERE clauses
$sql="SELECT eventID, eventTitle, te_events.catID, te_events.venueID, te_category.catDesc, te_venue.venueName, te_venue.location, eventStartDate, eventEndDate, eventPrice FROM te_events INNER JOIN te_category ON te_category.catID=te_events.catID INNER JOIN te_venue ON te_venue.venueID=te_events.venueID
WHERE ".
(!empty($wheres) ? implode(" AND ",$wheres) : '1=1').
"
ORDER BY eventTitle";
Here is html code :
<p><label class="label1">Event Title:</label><input type='text' class="input_personal" name='eventTitle' id ='eventTitle'/></p>
<p><label class="label1">Venue Name:</label></p>
<p><select class="select" name="venueID" id ='venueID' >
<option>Select</option>
<option value='v1'>Theatre Royal</option>
<option value='v2'>BALTIC Centre for Contemporary Art</option>
<option value='v3'>Laing Art Gallery</option>
<option value='v4'>The Biscuit Factory</option>
<option value='v5'>Discovery Museum</option>
<option value='v6'>HMS Calliope</option>
<option value='v7'>Metro Radio Arena</option>
<option value='v8'>Mill Volvo Tyne Theatre</option>
<option value='v9'>PLAYHOUSE Whitley Bay</option>
<option value='v10'>Shipley Art Gallery</option>
</select></p>
<p><label class="label1">Cetogry:</label></p>
<p><select class="select" name="catID" id ='catID'>
<option>Select</option>
<option value='c1'>Carnival</option>
<option value='c2'>Theatre</option>
<option value='c3'>Comedy</option>
<option value='c4'>Exhibition</option>
<option value='c5'>Festival</option>
<option value='c6'>Family</option>
<option value='c7'>Music</option>
<option value='c8'>Sport</option>
</select></p>
I wrote a code to search and filter the entered data and display the results back. In my data base I have 3 tables te_events , te_category and te_venue. So the problem with my code is that it doesn't display the catID and the venueID but all the other fields are fine. So can anyone help my to solve this problem.
Thanks