mysql_query.php : mysql_query « MySQL Database « PHP






mysql_query.php

 
<?php

   $mysqli = new mysqli("127.0.0.1", "root","", "mydatabase");

   $query = "SELECT productid, name, price FROM product ORDER by name";
   $result = $mysqli->query($query, MYSQLI_STORE_RESULT);

   while(list($productid, $name, $price) = $result->fetch_row())
      echo "($productid) $name: $price <br />";

   $result->free();

?>
  
  








Related examples in the same category

1.Add record to my_database/my_table
2.Adding a Row to a Table
3.Deleting Data
4.Get data from mysql
5.function mysql_query() queries the database.
6.Storing Information in a Database
7.Using PHP variables wherever you want inside SQL queries
8.Sign the guestbook