Use mysqli to fetch data from mysql : mysqli « MySQL Database « PHP






Use mysqli to fetch data from mysql

 
<?php

   $mysqli = new mysqli("127.0.0.1", "root","", "mydatabase");
   $query = "SELECT productid, name, price, description FROM product ORDER BY productid";

   $stmt = $mysqli->prepare($query);

   $stmt->execute();

   $stmt->bind_result($productid, $name, $price, $description);

   while($stmt->fetch()) {
      echo "$productid, $name, $price, $description <br />";
   }
   $stmt->close();
   $mysqli->close();

?>
  
  








Related examples in the same category

1.Multiple Queries Using MySQLi
2.Parameter Binding in MySQLi
3.Using the mysqli Object-Oriented API
4.Using the Object-Oriented Syntax in MySQLi
5.mysqli_fetch_object.php
6.mysqli_fetch_result-2.php
7.mysqli_fetch_result.php
8.mysqli_fetch_row.php
9.mysqli_free_result.php
10.mysqli_multi_query.php
11.mysqli_stmt_prepare.php
12.mysqli_store_result.php
13.retrieving_multiple_rows.php