Help with passing a variable!!!
Posted: Wed Feb 25, 2004 7:29 pm
I'm trying to filter a query by month of the year in its numeric value. However, what I'm doing doesn't seem to be working. If someone could help me out, I would appreciate it. Here's what I have for code... I know its not right, but I don't know whats not right about it.
Thanks in advance for the help!
Rand
Code: Select all
<?php
if (empty($POST)){
$query = "SELECT DATE_FORMAT(webcal_entry.cal_date, '%d %M %Y'),webcal_entry.cal_create_by,webcal_site_extras.cal_data,";
$query.= "webcal_entry.cal_description, DATE_FORMAT(webcal_entry_repeats.cal_end, '%d %M %Y') FROM webcal_entry,webcal_site_extras,webcal_entry_repeats ";
$query.= "WHERE webcal_entry.cal_id = webcal_site_extras.cal_id AND webcal_entry.cal_id = webcal_entry_repeats.cal_id ORDER BY webcal_entry.cal_date DESC";
}else{
$query = "SELECT DATE_FORMAT(webcal_entry.cal_date, '%d %M %Y'),webcal_entry.cal_create_by,webcal_site_extras.cal_data,";
$query.= "webcal_entry.cal_description, DATE_FORMAT(webcal_entry_repeats.cal_end, '%d %M %Y') FROM webcal_entry,webcal_site_extras,webcal_entry_repeats LOCATE('" . $POST["$filterdate"] . "', webcal_entry.cal_date)";
$query.= "WHERE webcal_entry.cal_id = webcal_site_extras.cal_id AND webcal_entry.cal_id = webcal_entry_repeats.cal_id AND webcal_entry.cal_date = '". $POST["$filterdate"] ."' ORDER BY webcal_entry.cal_date DESC";
}
$result = mysql_query ($query);
if (empty($id)){ // Checks the url to see if there is a value for $id.
$row = mysql_fetch_assoc ($result);
echo "<table border=3 cellpadding="1" bgcolor="#ffffff" width="100%">";
echo "<tr><td><center><img src="logo.jpg"></center><td><center><H1>Complete Reservation Data</H1></center></tr></td></table>";
echo $filterdate;
//echo "<tr><td colspan="2"><hr>";
// This next part is actually in HTML in my program, I just took it out of it for the coloring, so don't mind that part.
<table border="0" bgcolor="#FFFFFF">
<tr>
<form method="post" action="<?php echo $PHP_SELF?>">
<font type="Arial" size="10" color="red">
<td><SELECT NAME="filterdate">
<option value="200401">January</option>
<option value="200402">February</option>
<option value="200403">March</option>
<option value="200404">April</option>
<option value="200405">May</option>
<option value="200406">June</option>
<option value="200407">July</option>
<option value="200408">August</option>
<option value="200409">September</option>
<option value="200410">October</option>
<option value="200411">November</option>
<option value="200412">December</option>
</select>
<td><input type="Submit" name="submit" value="OK">
</font>
</form>
</table>
?>Rand