If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Create an option select from all rows of table as a singel string variable

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-03-09, 06:01
Iowarth Iowarth is offline
Registered User
 
Join Date: Aug 2009
Posts: 5
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.
while($Row=mysql_fetch_array($Result))
{
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.
Chris
Reply With Quote
  #2 (permalink)  
Old 08-03-09, 07:44
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
you're asking a php question in the mysql forum?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-03-09, 08:18
Iowarth Iowarth is offline
Registered User
 
Join Date: Aug 2009
Posts: 5
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.
Chris
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On