|
-
Mar 1st, 2012, 07:10 PM
#1
Addicted Member
Re: html select in php
Hi,
this code seems good, (I didn't change the PHP, but validated it as html code).
PHP Code:
while ($row = mysql_fetch_array($aJobs)) { $sOptionSelected = ''; if ($row['job_id'] == $jobId) { $sOptionSelected = 'selected="selected"'; } $sJobOptions = $sJobOptions.'<option value="'.$row['job_id'].'" '.$sOptionSelected.'>'.$row['job_desc'].'</option>'; }
q. from where do you get the value of $jobId?, please write more code
Feras Jobeir
-
Mar 1st, 2012, 07:22 PM
#2
Thread Starter
Hyperactive Member
Re: html select in php
this works for me, but i was wondering if there was another way of doing it in php. i just think its inefficient in terms of performance.
e.g. if i have a table with a 1000 row, for each row i call a function to query the jobs list and build a string of options, and select the appropriate option value
jobId is a variable passed to the called function.
thanks any way
-
Mar 1st, 2012, 07:36 PM
#3
Addicted Member
Re: html select in php
This depends on your data, how they locate in the database, are they related to others (so we can get them using the least number of queries).
To get a fine answer, please provide the SQL structure of your table(s), and describe a little on how do you want them to appear in the page. 
Feras Jobeir
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|