Results 1 to 5 of 5

Thread: html select in php

Hybrid View

  1. #1
    Addicted Member
    Join Date
    Feb 2010
    Location
    Damascus - Syria
    Posts
    145

    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

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2009
    Location
    sydney
    Posts
    265

    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

  3. #3
    Addicted Member
    Join Date
    Feb 2010
    Location
    Damascus - Syria
    Posts
    145

    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
  •  



Click Here to Expand Forum to Full Width