Basic multiple row select from MySQLi using PHP

January 24, 2024


$query = "SELECT * FROM items
WHERE deleted != 'y'
AND price > 0
ORDER BY id DESC
";

$stmt = $mysqli -> prepare($query);
$stmt -> execute();
$result = $stmt -> get_result();
$num_rows = $result -> num_rows;

if ( $num_rows > 0 ) {

while ( $item = $result -> fetch_assoc() ) {

echo = $item['id'] . ' < b r > ';
echo = $item['title'] . ' < b r > ';
echo = $item['price'] . ' < b r > ';

}
}



Comments

There are no comments.


Comment on this Article

Your email address will never be published. Comments are usually approved within an hour or two. (to prevent spam)