Jump to content

Listing current and future months on calendar


lauralee

Recommended Posts

Currently in my code I select the current month and future months to be shown on the calendar. I want to be able to have only the current month and future months shown automatically using the date function. Below is my code. How do I change the WHERE mo_id>09 in the code so that I don't have to change it manually every month and the only the current month and future months will display, not all of the month's names? $sql = @mysql_query('SELECT mo_id, month_name FROM month WHERE mo_id>09 ORDER BY mo_id'); if (!$sql) {exit('<p>Error performing query: ' . mysql_error() . '</p>');}while ($mos = mysql_fetch_array($sql)) { echo '<h2>' . $mos['month_name'] . '</h2><br />'; $items = @mysql_query('SELECT *FROM calendar WHERE mo ="' . $mos['month_name'] . '" OR "' . $mos['dt'] . '" ORDER BY dt, am_pm, hr, min'); if (!$items) {exit('<p>Error performing query: ' . mysql_error() . '</p>');}while ($each = mysql_fetch_array($items)) {echo '<p><em>' . $each['mo'] . ' ' . $each['dt'] . ' </em>' . $each['hr'] . ':' . $each['min'] . ' ' . $each['am_pm'] . ' - <span>' . $each['location'] . ' - ' . $each['title'] . '</span> - ' . $each['event'] . '</p>';}}?>

Link to comment
Share on other sites

That's easy: WHERE mo_id> " . $var . " ORDER BY assuming $var is a numeric else WHERE mo_id> " . '$var' . " ORDER BY

Edited by niche
Link to comment
Share on other sites

$sql = @mysql_query('SELECT mo_id, month_name FROM month WHERE mo_id>09 ORDER BY mo_id'); change it to <form method="post" name="form1"><select name="month" id="month"> <option selected="selected" value="01">01</option> <option value="02">02</option> <option value="03">03</option> <option value="04">04</option> <option value="05">05</option> <option value="06">06</option> <option value="07">07</option> <option value="08">08</option> <option value="09">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select><input type="submit" value="Post"></form> $month = $_POST['month]; $sql = @mysql_query('SELECT mo_id, month_name FROM month WHERE mo_id>'.$month.'ORDER BY mo_id');

Edited by JohnTipperton
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...