-2

hi i need some help again. can anyone do me a favor to convert my code from Mysql --> Mysqli I've been using mysql so im not that familiar yet with mysqli thanks in advance

Here is my php code that i want to convert

<?php
    $query = mysql_query("SELECT sched_ID, venue FROM tblschedule"); 
    echo '<select id="sched_ID" name="sched_ID"  class="form-control" >';
    echo '<option>-- Select Venue --</option>';
    while ($row = mysql_fetch_array($query)) 
    {
        echo '<option value="'.$row['sched_ID'].'">'.$row['venue'].'</option>';
    }
    echo '</select>';
 ?>
chris85
  • 23,846
  • 7
  • 34
  • 51

1 Answers1

1

To learn how to use mysqli syntax, please check the documentation here. Seems to me the mysqli syntax for your code would be:

<?php

    $query = "SELECT sched_ID, venue FROM tblschedule"; 
    echo '<select id="sched_ID" name="sched_ID"  class="form-control" >';
    echo '<option>-- Select Venue --</option>';
    $result = mysqli_query($dbconnection, $query) or die(mysqli_error($dbconnection));
    while ($row = mysqli_fetch_assoc($result)) 
        {
            echo '<option value="'.$row['sched_ID'].'">'.$row['venue'].'</option>';
        }
        echo '</select>';
 ?>
Morfinismo
  • 4,985
  • 4
  • 19
  • 36