I get this lines on web and just created a function name to that. The problem is: it is not working anymore and I dont know why, already tried things but nothing. Can someone help me please?
Code:
<?php
require 'PDOClasses/connection.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
function ShowCategories() {
$query = $db->query("SELECT id, name FROM categories ORDER BY name ASC");
$option = '';
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
$option .= '<option value = "'.$row['id'].'">'.$row['name'].'</option>';
}
}
?>
This is how I used to call:
<select id="category" name="category" tabindex="16" required>
<?php echo $option; ?>
</select>
This is how I'm calling now:
<select id="category" name="category" tabindex="16" required>
<?php ShowCategories(); ?>
</select>