In the database the value are in this format 1,6,7 but i fail to retrieve them into select menu, i have two query, i pass variable rows from the first query where i have specified select query which fetch data from database by using group_reg_no and i use that variable rows in the second query so that i can get specific activity selected
- require_once ("db_connection.php");
- if(isset($_GET['edit_id'])) {
- $edit_sql = "SELECT * FROM group_details WHERE group_reg_no = '$_GET[edit_id]'";
- $run_sql = mysqli_query($connection, $edit_sql);
- while ($rows = mysqli_fetch_assoc($run_sql)){
- $group_name = $rows['group_name'];
- $group_reg_no = $rows['group_reg_no'];
- $leader_name = $rows['leader_name'];
- $leader_contact = $rows['leader_contact'];
- $region = $rows['region'];
- $district = $rows['district'];
- $division = $rows['division'];
- $ward = $rows['ward'];
- $village = $rows['village'];
- $activity = $rows['activity'];
- $category = $rows['category'];
- $men = $rows['men'];
- $women = $rows['women'];
- $total = $rows['total'];
- }
- } else {
- $group_name = '';
- $group_reg_no = '';
- $leader_name = '';
- $leader_contact = '';
- $region = '';
- $district = '';
- $division = '';
- $ward = '';
- $village = '';
- $activity = '';
- $category = '';
- $men = '';
- $women = '';
- $total = '';
- }
- ?>
- ="activity" class="col-sm-2 control-label">Shughuli za Kikundi
- class="col-sm-3">
- ="form-control" name="activity[]" id="activity" multiple="multiple">
- >Select Activity
- $sel_activity = "SELECT * FROM activity";
- $run_activity = mysqli_query($connection, $sel_activity);
- while($rows = mysqli_fetch_assoc($run_activity)){
- $array = explode(',', $rows);
- foreach ($array as $rows) {
- if($activity == $rows['id']){
- $selected = 'selected';
- } else {
- $selected = '';
- }
- echo '';
- }
- }
- ?>
Loading
Replies
Know the answer? Post it — somebody with the same question will find it here.