Shi-ii Shi-ii - 1 month ago 12
PHP Question

mysqli_query() expects at least 2 parameters error

In PHP I'm trying to display all pages on page from database: but on my while loop I get this error:

I already got my SQL checked that is correct the only problem is on the while loop
Warning: MYSQLI_query() expects at least 2 parameters, 1 given

And this is my code:

<?php
$sql = "SELECT * FROM page";
$result = mysqli_query($connection, $sql);
while($row = mysqli_query($result)) {
?>
<?php echo "<a href='view_page.php?id=" . $row['id'] . "'>" . $row['title'] . "</a></li>"; ?>
<?php } ?>
</div>

Answer
<?php
$sql = "SELECT * FROM page";
$result = mysqli_query($connection, $sql);
while($row = mysqli_fetch_array($result)) {
?>
<?php echo "<a href='view_page.php?id=" . $row['id'] . "'>" 
. $row['title'] .   "</a></li>"; ?>
<?php } ?>
</div>
Comments