Page 1 of 1

Proper Syntax?

Posted: Fri Jun 21, 2002 7:23 am
by virgil
Hi

I am tring to query a MySQL database. The user selects the year and date from a dropdown menu. My question is "What is the proper syntax to select all the months OR just one."

The dropdown menu lists:

ALL
JAN
FEB
MAR
etc....

If the user selects "ALL" I want the query to return all the rows matching the "date_month" column.

Thanks for the advice. Virgil

Code: Select all

FROM eventpost WHERE date_year=$year_filter" AND date_month=month_filter;

    $result = mysql_query($query);
    check_mysql();
    while ($row=mysql_fetch_array($result, MYSQL_ASSOC))

Posted: Fri Jun 21, 2002 8:12 am
by mikeq
$query = "select * from eventpost where date_month='$month_filter'";

Date stuff

Posted: Fri Jun 21, 2002 9:12 am
by BDKR
If the user doesn't select a month, or selects all months, dont' include the "date = " stuff in the query statement.

Later on,
BDKR (TRC)