Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

My way learn MySQLI and PHP by examples

My way learn MySQLI and PHP by examples

MySQL is world most used database and when its works PHP then they have no match. Learning MySQL is very is one can found thousand of tutorial on net but these are now old as MySQLI(or MySQL Advanced) next version are now on demand as implementation is easy, secure and little bit faster. In this tutorial I am going to share Uses of MySQli in your next project.

MySQLI and PHP by examples

For Connecting to database, create a PHP file name dbsettings.php with following code :

$sanjay=new mysqli('localhost','root','','mysqlifirst');
if($sanjay->connect_errno){
echo $sanjay->connect_error;
}

I think above line is quite easy to understand, mysqlifirst is the name of your database.

Data query :
Suppose you have a table name billings which has coloumn trans_id, amount and so on.
Create a another file name dataquery.php with following code:

require('dbsettings.php');
$query="select * from billings where trans_id='2013' ";
$sendq=$sanjay->query($query);
$rows=$sendq->fetch_assoc();
echo "Transaction ID. 2013 amount is Rs.".$rows['amount'];

This is I think a very simple example of using MySqli. If you have any doubt then comment below , I will try to explain it later.
+Sanjay Prasad

3
Leave a Reply

avatar
3 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Fully HelpAli AtifCSS3Mania Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of
CSS3Mania
Guest

There are some quality design site which are sample show in this site. You can submit fresh site free download themes

Ali Atif
Guest

Informative Thanks for sharing dear.
Marvelloustechnologies.com

Fully Help
Guest

Nice blog…Very useful information is providing by ur blog. find Great beginning php tutorials Very clear and helpful for beginners.

Do you have any Query / Suggestion