Reply to Re: Displaying user defined select

Your name:

Reply:


Posted by Geoff Berrow on 10/11/06 09:24

Message-ID: <egi76o$mm9$1@yggdrasil.glocalnet.net> from Garry Jones
contained the following:

><option value="0" <?= $slt_tid0 ?> >00.00</option>
><option value="1" <?= $slt_tid1 ?> >00.01</option>
><option value="2" <?= $slt_tid2 ?> >00.02</option>
><option value="3" <?= $slt_tid3 ?> >00.03</option>
><option value="4" <?= $slt_tid4 ?> >00.04</option>
>
>if i was to continue I would end with
>
><option value="3599" <?= $slt_tid3599 ?> >23.59</option>
>
>because the values represent the minutes of the days in a timetable. Then I
>would test each variable against the output queried from MySQl with this

Well the good news is you don't need 3600. There are only 1440 minutes
in a day.

A loop is the answer

<?php
echo"<select name='select'>\n";
// put the selected variable here, could come from a db or could be the
// POSTed value. e.g
// $var=(isset($_POST['select']))?"$_POST['select']":0;
//I'll put $var=50 to test it.

$var=50;
for($i=0;$i<1440;$i++){
$selected=($var==$i)?" selected":"";
echo "<option value='$i'$selected>".date("H:i",$i*60)."</option>\n";
}
echo "</select>\n";
?>



--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

[Back to original 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

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