|
Posted by Jochem Maas on 01/10/06 19:15
Adrian Bruce wrote:
> the quickest solution and one that is easy to understand, I am no php
> expert and have never claimed as such so why 'noob'?
>
> Why is this such a poor method? if i type the HTML to be outputted
> correctly then what validation is required? also I think Someone new
> would run from your proposed solution
I don't really care if she runs. actually if she is liable to run then
that probably saves us here a lot of 'silly' questions ;-)
her original question:
"Is there a way to display data from database for Select Options in a form?"
the short answer is: 'yes'
but the way her original question was posted suggests that maybe she has
_absolutely_ no idea about how to use php... I mean google is able to
help her in theory:
http://www.google.com/search?num=100&q=generate+dynamic+select+box+PHP
either she has no idea what to search for or she was to lazy to try -
if the former then she should have not be ashamed to keep asking away, if
the latter then, well, who cares.
the reason I gave her what might be more than she can chew (the function)
was because:
a, her initial question was a bit vague (or rather broad)
b, to show that there can be a little more to generating dynamic elements
like select box.
c, to encourage generic code.
d, test her and she what her reaction is (hopefully she won't run away; instead
maybe she'll come back with a more specific question and DB data extraction)**
** heck I'm on this list for fun :-)
>
> Jochem Maas wrote:
>
>> teaching noobs to output html while (oun intended) looping thru a
>> result set is counter-productive. discuss.
>>
>> Adrian Bruce wrote:
>>
>>> Something along these lines will work fine
>>>
>>> <?php
>>> $query = mysql_query("select dates from table ") or die (mysql_error());
>>>
>>> echo"<select name='test'>";
>>>
>>> while ($row = mysql_fetch_array($query, MYSQL_NUM)){
>>> echo"<option value='$row[0]'>$row[1]</option>";
>>>
>>> }
>>> echo"</select>";
>>> ?>
>>>
>>> Regards
>>> Ade
>>>
>>> Sue 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!
>>>>
>>>> Thanks!
>>>> Sue
>>>>
>>>>
>>>
>>
[Back to original message]
|