Page 1 of 1

Display only january from database

Posted: Sun Feb 23, 2003 6:18 pm
by adrian28uk
I managed to get my availability calender working. I put together the database and other bits and then found some code and did a bit of trial and error on it. The variables from database are called in to the following script. If the field has the word check inside it then the date is turned to bold,red with a strikethorugh. I would like to know how I can just display the month of january.
Your help would be appreciated.

//database stuff goes here ect, to big to list

<?
$time=mktime(12,0,0,1,1,date("Y"));
$endtime=mktime(10,0,0,1,1,date("Y")+1);

while ($time<$endtime) {
$name=strtolower(date("Mj", $time));
if ($$name==''){ ?>
<? echo"$name"; ?>
<? } elseif ($$name=='check') { ?>
<s><strong></b><font color="red"><? echo"$name"; ?></s></strong></b></font>
<? } ?>
</td>
<td> <?
$time+=24*3600;
}

?>

<?
++$i;
}
?>

Posted: Mon Feb 24, 2003 7:49 am
by Stoker
If you post your query it would be easier to manipulate it.. in general

$q = "SELECT col1,col2,col3 FROM table WHERE somedate >= '$mystartdate' AND somedate <= '$myenddate'";

Posted: Mon Mar 10, 2003 11:39 am
by matthiasone
I found that just it simplier if you want all entries for a single month to create a query like this:

Code: Select all

$query = "SELECT col1,col2,col3 FROM table WHERE MONTH(somedate) = 1;

Posted: Mon Mar 10, 2003 1:15 pm
by Stoker
would be interresting to see a speed/resource comparison test of a large-table query using the MONTH() function versus direct value comparison..