Jump to content

Listbox with checkboxes in PHP and MYSQL


Dharmender

Recommended Posts

I want to create listbox with checkboxes in PHP. The data is comming from Mysql table

Table is supplierinfo with id and name.

Mysql Query is "select id,name from supplierinfo"

 

I want to have id as option value and name as text.

The listbox wtih multiple select option will have checkboxes with options just like Treeview with Checkboxes.

PHP code is <select name="info[]" multiple>

<option value=$id>$name</option>

</select>

I am not sure what you are actually trying... But this is an example how we create a list box dynamically with Database values..

 

$query="select id,  name from supplierinfo";
$result = mysqli_query( $dbc, $query);

  	 echo '<select name="" >';
     	 while( $row = mysqli_fetch_array($result, MYSQLI_NUM)) {
                      echo '<option value="' . $row[0] . '">' . $row[1] . '</option>';    
             }
  	 echo '</select>';  

 

Is this what you are searching?

I am not sure what you are actually trying... But this is an example how we create a list box dynamically with Database values..

 

$query="select id, name from supplierinfo";
$result = mysqli_query( $dbc, $query);

 echo '<select name="" >';
 	 while( $row = mysqli_fetch_array($result, MYSQLI_NUM)) {
echo '<option value="' . $row[0] . '">' . $row[1] . '</option>';
}
 echo '</select>'; 

 

Is this what you are searching?

 

I know this procedure. What I want is every option should have checkbox before it.

Check this link http://demo.koolphp.net/Examples/KoolListBox/Features/CheckBoxes/index.php

I am not sure what you are actually trying... But this is an example how we create a list box dynamically with Database values..

 

$query="select id, name from supplierinfo";
$result = mysqli_query( $dbc, $query);

 echo '<select name="" >';
 	 while( $row = mysqli_fetch_array($result, MYSQLI_NUM)) {
echo '<option value="' . $row[0] . '">' . $row[1] . '</option>';
}
 echo '</select>'; 

 

Is this what you are searching?

I want listbox as given here http://demo.koolphp.net/Examples/KoolListBox/Features/CheckBoxes/index.php

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.