Re: Is there a way to display data from database for Select Options in a form?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jochem: Your method is long, probably takes more time to run, and is
therefore inefficient in this circumstance. There is a time and place
for a good solid reusable function, or even a class.

Of course things could go wrong when using mySQL connections, but
things can always go wrong.

Bringing people to use PHP on a higher standard? I am sorry, but that
is simply childish. There are plenty of kids that think their way in
programming is the best possible way, the only good way, and that
everyone else should try to imitate them.  They also think that every
problem should be solved in the language they are strongest with.
Eventually one must learn that for every way of doing something, there
are at least 5 other ways. Higher standards? Or YOUR standards?

The situation determines the standards, not the programmer.

On 1/10/06, Mike Smith <mikeosmith@xxxxxxxxx> wrote:
> On 1/10/06, Sue <skot1@xxxxxxxxxxxx> wrote:
> > Hello,
> >
> > We have a form that contains a Select option for a listing of available
> > dates for the user to choose from.  Right now we have to manually change the
> > dates within the form's Selection list as new dates become available to
> > choose from.  We currently store these available dates in our database, and
> > am wondering if we can somehow extract these dates from the table to display
> > in our form?  This would eliminate alot of maintenance needed to this form.
> > If anyone has any ideas as to reference material etc. that I may look which
> > would give me an idea how to do this using PHP, I'd appreciate it!
> How about...
>
> $format = "m/d/Y";
> $sql = "SELECT datefield FROM table";
> $results = $whatever_db_abstraction_your_using_to_execute__sql($sql);
>
> <select name="date">
> <?php
> foreach($results AS $result){
> echo "<option>".date($format,strtotime($result))."</option>";
> }
> ?>
> </select>
>
> http://us2.php.net/manual/en/function.strtotime.php
> http://us2.php.net/manual/en/function.date.php
>
> Mike
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux