PHP Tutorial : Extracting rows from mysql

Helllooooooo,
In latest two posts I have shown you how to connect to a mysql database via PHP, and in another one I teach you how to select rows from a mysql database table. In this one I will show you how to extract that rows from mysql and print them out into a page. Let’s suppose we have a database which contains fields : id, full_name, age. Ok, next step is connecting to db, then making a query to select those fields and finally extract & print them on the screen :

$query_db = "select * from table_Name";
$result_db = mysql_query($query_db);

while($row=@mysql_fetch_object($result_db) {
print "$row->full_name it's $row->age years old";
}

We used a while() loop to extract all results!

Isn’t PHP rocking?

This entry was posted in Php & MySQL and tagged , , , , , , , , , . Bookmark the permalink.

2 Responses to PHP Tutorial : Extracting rows from mysql

  1. bogdan says:

    Would have been worth it to mention the other option: mysql_fetch_array. After all, everyone learns basic programming first and then the concept of OOP and how to work with it.

  2. admin says:

    ok, appreciate your advice but honestly it’s my blog and I make the rules here

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>