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

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`)

)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.