|
Posted by Patrick on 05/18/06 18:03
Patrick wrote:
> Hello All,
>
> Kind of new to PHP. I have an html form where a person inputs a date via
> a drop down select. How do I make php put a zero in front of the numbers
> 1-9 ie. 01 02 03 when writing to the file? I have tried making the
> value="01" etc. but this doesn't work. Below is a snippet of my form and
> the code I am using to write to the file. I hope I have made myself
> clear enough. Your help is greatly appreciated.
>
>
> //form part
> <select class="inform" name="logday">
> <option value="1">1
> <option value="2">2
> <option value="3">3
> <option value="4">4
> <option value="5">5
> <option value="6">6
> <option value="7">7
> <option value="8">8
> <option value="9">9
> <option value="10">10
> etc,
>
> //code part
> fputs($out,"$_POST[logday] ");
>
>
> Thanks,
> Patrick
I figured it out.
$logday = $_POST[logday];
and then
fprintf($out,"%02d",$logday);
instead of the fputs, which gives me my leading zero.
Patrick
--
Patrick A. Smith Assistant System Administrator
Ocean Circulation Group – USF - College of Marine Science
http://ocgweb.marine.usf.edu Phone: 727 553-3334
The trouble with doing something right the first time is that nobody
appreciates how difficult it was. - La Rochefoucauld
[Back to original message]
|