Display only january from database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
adrian28uk
Forum Newbie
Posts: 2
Joined: Fri Feb 21, 2003 2:24 am

Display only january from database

Post 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;
}
?>
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post 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'";
matthiasone
Forum Contributor
Posts: 117
Joined: Mon Jul 22, 2002 12:14 pm
Location: Texas, USA
Contact:

Post 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;
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

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