Function DropdownList -Please Help Me

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
azri_bech
Forum Newbie
Posts: 14
Joined: Fri Aug 07, 2009 11:15 pm

Function DropdownList -Please Help Me

Post by azri_bech »

I'm new php programmer
Query Form: using dropdownlist, the value consist:
<select>
<option value="today">Today</option>
<option value="LastWeek">Last week</option>
<option value="LastMonth">Last Month </option>
<select>

how to build the function and how the function can call the value to display the result.

Please help to resolve my problems.
Thank You,
azri_bech
Forum Newbie
Posts: 14
Joined: Fri Aug 07, 2009 11:15 pm

Re: Function DropdownList -Please Help Me

Post by azri_bech »

when user select date range from dropdownlist,
the result will be display on the query form.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Function DropdownList -Please Help Me

Post by aceconcepts »

If you can determine an initial date i.e. today then you can use mktime() to get past and future dates/times etc...

Take a look at http://us.php.net/manual/en/function.mktime.php
azri_bech
Forum Newbie
Posts: 14
Joined: Fri Aug 07, 2009 11:15 pm

Re: Function DropdownList -Please Help Me

Post by azri_bech »

i dont know how to build the function. can you help me how to build a simple function to display the result when user select from dropdownlist..Thanks
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Function DropdownList -Please Help Me

Post by cpetercarter »

You need to do some reading on how php forms work.

You display a form on a page. The user choses from the drop-down menu, and then clicks "submit". The user's browser sends the chosen value to the server as a $_POST value. The server can then send a new web page back to the browser which displays the chosen value.

Like this script, which you can run as test.php:

Code: Select all

<?php
 
if (!isset($_POST['time']))  {
 
    echo '<form action="test.php" method="post" enctype="multipart/form-data">';
    echo '<select name="time">';
    echo '<option value="today">Today</option>';
    echo '<option value="LastWeek">Last week</option>';
    echo '<option value="LastMonth">Last Month </option>';
    echo '</select>';
 
    echo '<input type="submit" value="submit" />';
 
    echo '</form>';
 
}  else  {
 
echo "The value you chose was ".$_POST['time'];
 
}
 
?>
 
azri_bech
Forum Newbie
Posts: 14
Joined: Fri Aug 07, 2009 11:15 pm

Re: Function DropdownList -Please Help Me

Post by azri_bech »

Thank you so much :)
Post Reply