Dharmender Posted January 10, 2013 Share Posted January 10, 2013 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> Link to comment https://forums.phpfreaks.com/topic/272928-listbox-with-checkboxes-in-php-and-mysql/ 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 . Link to comment https://forums.phpfreaks.com/topic/272928-listbox-with-checkboxes-in-php-and-mysql/#findComment-1404595 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? Link to comment https://forums.phpfreaks.com/topic/272928-listbox-with-checkboxes-in-php-and-mysql/#findComment-1404597 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 Link to comment https://forums.phpfreaks.com/topic/272928-listbox-with-checkboxes-in-php-and-mysql/#findComment-1404604 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 Link to comment https://forums.phpfreaks.com/topic/272928-listbox-with-checkboxes-in-php-and-mysql/#findComment-1404606 Share on other sites More sharing options...
thara Posted January 10, 2013 Share Posted January 10, 2013 don't use a listbox... try with checkbox standalone. Link to comment https://forums.phpfreaks.com/topic/272928-listbox-with-checkboxes-in-php-and-mysql/#findComment-1404607 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... Link to comment https://forums.phpfreaks.com/topic/272928-listbox-with-checkboxes-in-php-and-mysql/#findComment-1404609 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.