Posted by Justin Koivisto on 05/18/06 17:16
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] ");
use something more like:
fputs($out,sprintf('%02d',intval($_POST['logday'])));
[Back to original message]
|