hi , i'm a newbie at php, and can someone help me with codes

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
Jemmo2Grand
Forum Newbie
Posts: 1
Joined: Tue Aug 24, 2004 1:20 am

hi , i'm a newbie at php, and can someone help me with codes

Post 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! :D
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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.
Last edited by anjanesh on Tue Aug 24, 2004 1:46 am, edited 2 times in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I would really get out of the habbit of escaping php like that....

oh the uglyness....
User avatar
fresh
Forum Contributor
Posts: 259
Joined: Mon Jun 14, 2004 10:39 am
Location: Amerika

Post by fresh »

LMFAO.. hey but if it works who cares :D
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Well I would care if I had to maintain it.... 8O
Post Reply