You are here: Re: help putting zero in front of single digits in select « PHP Programming Language « IT news, forums, messages
Re: help putting zero in front of single digits in select

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'])));

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация