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>

Edited by Dharmender
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

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.