Jump to content

Recommended Posts

how to put text in combo box at run time...

 

 

 

 

 

<select name="cmbsuppid" id="cmbissueid" onchange="showSupplier(this.value)";>

   

    <?php

 

    include('connect.php');

 

    $Tb = "booksupp_master";

 

    mysql_select_db($Db, $link);

                           

    $query = "select supp_id from $Tb order by supp_id";

 

    $result= mysql_query($query,$link);

 

    $fel=mysql_num_fields($result);

    $nro=mysql_num_rows($result);

 

    if ($nro>0)

 

    {

   

       

        echo "<option>-- Select Supplier --</option>\n";   

       

    while ($row=mysql_fetch_array($result))

 

        {

   

            echo "<option value='$row[supp_id]'>$row[supp_id]</option>\n";

       

        }                       

                             

    }

 

    mysql_close($link);

   

     

  ?>

       

 

 

 

 

 

 

 

above is my code i m picking up value from mysql.. but how can i put text in it.

 

 

or how can i move combobox at run time ??

Link to comment
https://forums.phpfreaks.com/topic/188429-how-to-put-value-into-comobox/
Share on other sites

Also if you want to display any other text from table then you need to add field name in query and you drop down will be like this.

while ($row=mysql_fetch_array($result))

        {
    
            echo '<option value="'.$row['supp_id'].'">'.$row['TXTFIELD'].'</option>\n';
        
        }

 

check the TXTFIELD in drop down, just replace your field name there

not working dear

 

Actually what i want to do is that... I am having modification form .. in which i m displaying value of previous selected supplier. I also want to fill this option box with all supplier ids ,, so in case if user selected wrong supplier id in addform , he/she can modify it in modification form.

 

 

 

Also if you want to display any other text from table then you need to add field name in query and you drop down will be like this.

while ($row=mysql_fetch_array($result))

        {
    
            echo '<option value="'.$row['supp_id'].'">'.$row['TXTFIELD'].'</option>\n';
        
        }

 

check the TXTFIELD in drop down, just replace your field name there

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.