Page 1 of 1
hi , i'm a newbie at php, and can someone help me with codes
Posted: Tue Aug 24, 2004 1:20 am
by Jemmo2Grand
I need codes that basically have the first page asking for user input which is the specified date period.
e.g
From: to:
(input date) (input date)
Then within this range the next page will execute my sql syntax. At this moment i can't narrow down the results to the specified date. I'm using access database.
Thanks!

Posted: Tue Aug 24, 2004 1:39 am
by anjanesh
Code: Select all
<SELECT NAME=FromDate>
<?php
for ($i=1;$i<=31;$i++)
echo '<OPTION '.(isset($_POST['FromDate'])?$_POST['FromDate']==$i?' SELECTED':'':'').'>'.$i.'</OPTION>';
?>
</SELECT>
<SELECT NAME=FromMonth>
<?php
$arrMonths=array("January","February","March","April","May","June","July","August","September","October","November","December");
for ($i=0;$i<count($arrMonths);$i++)
echo '<OPTION VALUE="'.($i+1).'" '.(isset($_POST['FromMonth'])?$_POST['FromMonth']==($i+1)?' SELECTED':'':'').'> '.$arrMonths[$i].'</OPTION>';
?>
</SELECT>
<SELECT NAME=FromYear>
<?php
for ($i=1950;$i<=1985;$i++)
echo '<OPTION '.(isset($_POST['FromYear'])?$_POST['FromYear']==$i?' SELECTED':'':'').'>'.$i.'</OPTION>';
?>
</SELECT>
<SELECT NAME=ToDate>
<?php
for ($i=1;$i<=31;$i++)
echo '<OPTION '.(isset($_POST['ToDate'])?$_POST['ToDate']==$i?' SELECTED':'':'').'>'.$i.'</OPTION>';
?>
</SELECT>
<SELECT NAME=ToMonth>
<?php
$arrMonths=array("January","February","March","April","May","June","July","August","September","October","November","December");
for ($i=0;$i<count($arrMonths);$i++)
echo '<OPTION VALUE="'.($i+1).'" '.(isset($_POST['ToMonth'])?$_POST['ToMonth']==($i+1)?' SELECTED':'':'').'> '.$arrMonths[$i].'</OPTION>';
?>
</SELECT>
<SELECT NAME=ToYear>
<?php
for ($i=1950;$i<=1985;$i++)
echo '<OPTION '.(isset($_POST['ToYear'])?$_POST['ToYear']==$i?' SELECTED':'':'').'>'.$i.'</OPTION>';
?>
</SELECT>
Use $_POST['FromDate'],$_POST['FromMonth'],$_POST['FromYear'] and $_POST['ToDate'],$_POST['ToMonth'],$_POST['ToYear'] to figure out the range.
Posted: Tue Aug 24, 2004 1:40 am
by John Cartwright
I would really get out of the habbit of escaping php like that....
oh the uglyness....
Posted: Tue Aug 24, 2004 3:50 am
by fresh
LMFAO.. hey but if it works who cares

Posted: Tue Aug 24, 2004 6:32 am
by CoderGoblin
Well I would care if I had to maintain it....
