Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009

    Unanswered: Create an option select from all rows of table as a singel string variable

    I have a page which includes numerous images generated from a MySQL table each with its own form/drop-down box. The values in the drop down box are identical in all cases and limited in number - maximum 10.
    It is very easy to create a query to create the drop down box within the Select i.e.
    print ("<option value='$Row[id]'>$Row[size] - $Row[price]</option>\n");
    This produces for example:-
    <option value='1'>6ins x 4ins - 5.50</option>
    <option value='2'>8ins x 5ins - 7.50</option>

    But, I don't want to repeat this query with every picture for obvious reasons.
    So, how can I run the query just once on the page and load the entire output into a single string to use within each Select?
    example required result:-
    $optionstr="<option value='1'>6ins x 4ins - 5.50</option><option value='2'>8ins x 5ins - 7.50</option>";
    I am sure there is a simple solution which is evading my simple brain!
    Assistance appreciated.

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    you're asking a php question in the mysql forum? | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Aug 2009
    Yes - firstly because my simple mind didn't separate the two in this instance and secondly because the answer, for all I know, might rest in the query rather than the PHP manipulation.
    I can't see how to delete/transfer this question so have re-posted it with apologies in the PHP forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts