Jump to content

how to put data of sql in combo box


subash85

Recommended Posts

i dun have any idea . i juz use...$insert_data="insert into  to insert data in mysql but i dun know about how to display data in list/menu (combo) box.. soo..i m needed for help if u can anyone give me tutorials about list/menu (combo) box that how to fetch data of mysql in to php form type in combo

Link to comment
Share on other sites

here's the cod which i have used for fetching the data to select box from the sql...

<?php

$query1="select * from type order by user_id";

  $result1=mysql_query($query1);

$i=0;

while ($a_row=mysql_fetch_array($result1))

{

global $i;

$i++;

$db_id=$a_row['id'];

$db_user_type=$a_row['user_type'];

print "<select name=\"new_user_type\" id=\"new_user_type\">

                      <option></option>

                      <option>$db_user_type</option>

                      </select>

                    ";

}

?>

 

.......................

SQL

 

CREATE TABLE `type` (

  `id` int(11) NOT NULL auto_increment,

  `user_type` varchar(100) NOT NULL,

  PRIMARY KEY  (`id`,`user_type`)

)

Link to comment
Share on other sites

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.