Dharmender Posted January 10, 2013 Share Posted January 10, 2013 (edited) 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 January 10, 2013 by Dharmender Quote Link to comment Share on other sites More sharing options...
requinix Posted January 10, 2013 Share Posted January 10, 2013 1. What is your question? 2. Spoiler: you can't do it with just a . Quote Link to comment Share on other sites More sharing options...
thara Posted January 10, 2013 Share Posted January 10, 2013 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? Quote Link to comment Share on other sites More sharing options...
Dharmender Posted January 10, 2013 Author Share Posted January 10, 2013 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 Quote Link to comment Share on other sites More sharing options...
Dharmender Posted January 10, 2013 Author Share Posted January 10, 2013 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 Quote Link to comment Share on other sites More sharing options...
thara Posted January 10, 2013 Share Posted January 10, 2013 (edited) don't use a listbox... try with checkbox standalone. Edited January 10, 2013 by thara Quote Link to comment Share on other sites More sharing options...
thara Posted January 10, 2013 Share Posted January 10, 2013 your demo link shows it clearly.. You can use a DIV to place your check-boxes and style it with CSS... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.