Proper Syntax?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
virgil
Forum Commoner
Posts: 59
Joined: Thu Jun 13, 2002 11:43 pm
Location: New York, U.S.

Proper Syntax?

Post 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))
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

$query = "select * from eventpost where date_month='$month_filter'";
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Date stuff

Post 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)
Post Reply