It works fine when put inside a SELECT in a form, as follows:
Code: Select all
<label for="_Exhibitor1">Exhibitor 1</label>
<select name="_Exhibitor1" size="1">
<option selected value=""> </option>
<?php
$getexhibitor = $conn->query("SELECT * FROM exhibitors WHERE Status NOT LIKE 'Archived'");
while ($row = $getexhibitor->fetch_assoc()) {
echo '<option value="'.$row["CompanyName"].'">'.$row["CompanyName"].'</option>';
$count++;
}
?>
</select>
I created a functions.php file and in my main page (where the form is), I put an include:
Code: Select all
include ('include/functions.php');
Code: Select all
<?php
include ('dbconnect.php');
function GetExhibitorList() {
$getexhibitor = $conn->query('SELECT * FROM exhibitors WHERE Status NOT LIKE "Archived"');
while ($row = $getexhibitor->fetch_assoc()) {
echo '<option value="'.$row["CompanyName"].'">'.$row["CompanyName"].'</option>';
$count++;
}
}
?>
Code: Select all
<label for="_Exhibitor1">Exhibitor 1</label>
<select name="_Exhibitor1" size="1">
<option selected value=""> </option>
<?php GetExhibitorList(); ?>
</select>
Any ideas? Thanks!