|
Posted by Reinhart Viane on 02/23/05 20:18
This is how I would do it, don't know if it is the best way.
A. get the date out of the database
Let's say $maindate is that date you retrieved from the database
B. split up the date into several parts for day month and year The day as a
number (dd):
$day=date ("j", strtotime($maindate));
The month as a number (mm):
$month= date ("m", strtotime($maindate));
The month as a number (yy):
$year= date ("Y", strtotime($maindate));
C. Now in your combobox you must do something like:
<select name="comboday">
<?PHP
for($aday=01;$aday<32;$aday++)
//fill the combobox with the numbers 1-31
{
echo('<option value="'.$aday.'"');
if($day==$aday)
{
//if the day from the database equals this aday then echo selected so that
//day is selected in the combobox
echo(" selected");
}
echo('>'.$aday.'</option>');
}
?>
</select>
That should do the trick
Greetz
Reinhart
-----Oorspronkelijk bericht-----
Van: K Karthik [mailto:kkarthik@adventnet.com]
Verzonden: woensdag 23 februari 2005 13:41
Aan: php-general@lists.php.net
Onderwerp: [PHP] help me
dear sir,
i'd like to get a date from my database(mysql).and then show a combobox
of calendar(date-month-year) with the retrieved data selected.
can you help me doing this?? am new to php.
thanks,
karthikeyan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005
Navigation:
[Reply to this message]
|