Share on Google+Share on Google+

PHP MySQLi Query

In the current tutorial we will study how to make query in mysqli, the example will make the concept more clear.


It performs a query in specified database, the format is as follows:

Object Oriented Style:

mixed mysqli::query ( string $query [, int $resultmode ] )

Procedural Style:

mixed mysqli_query ( mysqli $link , string $query [, int $resultmode ] )

There are three parameters are present in it, link, query and resultmode.

In the example below though it is similar to previous example, but to maintain the ease of understand we put the same example.



$db=new mysqli("localhost","root","","rose");



printf("Connection failed:%s \n",mysqli_connect_error());



$result=$db->query("select name from student");

printf("Affected rows:%d \n",$db->affected_rows);


Affected rows :- 1



Posted on: May 1, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.