I have this code:
<?php
$user = new User();
$sql = DB::getInstance()->get('modules', array(
'username',
'=',
$user->data()->username
));
if (!$sql->count())
{
echo 'No data';
}
else
{
foreach($sql->results() as $sql)
{
?>
<select>
<option value="module"><?php
echo $sql->name; ?> </option>
</select><?php
}
} ?>
My aim was to make the result of the query appear as a dropdown list but it appears side by side as a dropdown of its own. I'm not sure what I'm doing wrong.
I also have buttons which I queried that way (not in a dropdown), they all appear but only one button is clickable and goes to the next page. I queried it as I queried the data for the dropdown and displayed the button this way:
<p><button class=" btn btn-danger btn-lg btn-block" id="test"> <?php echo $sql->name; ?></button></p>
<script>
$(document).ready(function () {
$("#test").click(function () {
window.location = "#?name=" + $("#test").text();
});
});
</script>
So, when I click the first button, it goes to the next page but nothing happens when I click the others. I think the problem might be the way I'm displaying them.
Aucun commentaire:
Enregistrer un commentaire