ok. try this.
ahven't tested it though ...

 <form name="thisForm" action = "<?php print $PHP_SELF ?>">
 
?<php

// to dump out the months
$months = Array("January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December");
echo '<select name="sortMonth" onChange="document.thisForm.Submit()"';
for ($x=1; $x <= count($months); $x++)
        {
        print "\t<option value=\"$x\" ";
        print ($x == $month) ? " SELECTED":" ";
        print ">".$months[$x-1]."\n";
        }
echo ' </select> ';

?>

then something like (pref before the dump of months)

<?php

if (isset($sortMonth))
{
 $sql = "SELECT * FROM $table_cal WHERE item_activity='$id' AND 
 DATE_FORMAT('item_date','%b')='$sortMonth'";

// then the rest of the code for the query

}


the real crux is that the var whihc is the name of the <select> will be
populated when the form refreshes and then isset() will say it has a value
and drop inside to create the query. that way you avoid an expensive if or
or or or ...



Steve 

> -----Original Message-----
> From: Russ Michell [mailto:[EMAIL PROTECTED]]
> Sent: 26 April 2001 10:50
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Query problem cont'd..
> 
> 
> Hi there:
> 
> I'm stil having problems with this query in that it doesn't 
> bring up any results!
> Here is the <select> menu that refreshes the page and 
> deposites the var: 'sortedBy' into play:
> 

> <option>--select one--</option>
> <option value=\"$PHP_SELF?sortedBy=Jan\">Jan</option>
> <option value=\"?sortedBy=Feb\">Feb</option>
> <option value=\"$PHP_SELF?sortedBy=Mar\">Mar</option>
> <option value=\"$PHP_SELF?sortedBy=Apr\">Apr</option>
> <option value=\"$PHP_SELF?sortedBy=May\">May</option>
> <option value=\"$PHP_SELF?sortedBy=Jun\">Jun</option>
> <option value=\"$PHP_SELF?sortedBy=Jul\">Jul</option>
> <option value=\"$PHP_SELF?sortedBy=Aug\">Aug</option>
> <option value=\"$PHP_SELF?sortedBy=Sep\">Sep</option>
> <option value=\"$PHP_SELF?sortedBy=Oct\">Oct</option>
> <option value=\"$PHP_SELF?sortedBy=Nov\">Nov</option>
> <option value=\"$PHP_SELF?sortedBy=Dec\">Dec</option>
> </select>
> </form>
> 
> The SQL qery:
> 
> if(
> ($sortedBy == 'Jan') || ($sortedBy == 'Feb') || ($sortedBy == 
> 'Mar') || 
> ($sortedBy == 'Apr') || ($sortedBy == 'May') || ($sortedBy == 
> 'Jun') ||
> ($sortedBy == 'Jul') || ($sortedBy == 'Aug') || ($sortedBy == 
> 'Sep') || 
> ($sortedBy == 'Oct') || ($sortedBy == 'Nov') || ($sortedBy == 'Dec')
> ) 
> {
> $sql = "SELECT * FROM $table_cal WHERE item_activity='$id' AND 
> DATE_FORMAT('item_date','%b')='$sortedBy'"; 
> }
> 
> Thanks to Rasmus for helping me out so far!
> Can anyone see what I may be doing wrong???
> 
> I'm using mysql-3.22.32 and the item_date column is a MySQL 
> DATE() column..
> 
> Cheers:
> Russ
> 
> #-------------------------------------------------------#
>                               
>          "Believe nothing - consider everything"      
>            "Web Developers do it on-the-fly."
>                                                       
>   Russ Michell
>   Anglia Polytechnic University Webteam
>   
>   e: [EMAIL PROTECTED]
>   w: www.apu.ac.uk/webteam
>   t: +44 (0)1223 363271 x 2331
> 
>   www.theruss.com
>                       
> #-------------------------------------------------------#
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: 
> [EMAIL PROTECTED]
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to