I'm a beginner and I can't figure out for the life of me how to list products from a mysqli table on a webpage using php. Currently I just manage to get the first row to repeat for the number of rows that exist in the table using the following code:
<?php
$p_sql = "SELECT * FROM products";
$p_query = mysqli_query($db_conx, $p_sql);
$productData = mysqli_fetch_array($p_query, MYSQL_ASSOC);
$num = mysqli_num_rows($p_query);
?>
<!DOCTYPE html>
<?php print "There are currently $num rows in the table<P>";
for ($row=0; $row<$num; $row++){
$name = $productData["product_name"];
echo "$name <br>";
};
?>
I know within my for loop I don't include $row
but I don't know how to properly include it. Your help would be much appreciated!