How To View The Record In PHP And MYSQL Database?

How To View Record In PHP And MYSQL Database?

How to view the record in PHP and MYSQL database?

In this tutorial, we will try to learn the about the view of records in the database table in PHP and MySQL.

Code of view of records in the database table in PHP and MySQL.

<?php
mysql_select_db('publisher',mysql_connect('localhost','root',''));
?>
<html>
<body>
<table border="1">
<?php
$books_query=mysql_query("select * from books");
while($books_rows=mysql_fetch_array($books_query)){
?>
<tr>
<td><?php echo $books_rows['BookID'] ; ?></td>
<td><?php echo $books_rows['BookTitleAttribute'] ; ?></td>
</tr>
<?php }?>
</table> 
</body>
</html>

Line 1 to 3: Database Connection and the database name is “publisher”.

Line 8: mysql_query  function display the data from all the rows in table “books”. And all the data is handed over to the variable $books_query.

Line 9: mysql_query  function returns the records with the help of variable “$books_query”.  Here, the variable “$books_query” is a variable containing  MySQL query “select * from books”.

Line 12: $books_rows[‘BookID’] gets the BookID from database attribute name as “BookID” as shown below in database view.

Line 12, 13: “BookID” and “BookTitleAttribute” are the attributes of the database table.

Database view in PHP Myadmin

Database insert delete view update in php mysql

Figure: Database insert delete view update in PHP MySQL

 

 

Fazal Rehman Shamil Click Here to Know More
Instructor, Researcher, Blogger, SEO Expert, Poet and Publisher of International Journal Of Software, Technology & Science ISSN : 2616 - 5325
Dear Professors and Resarchers!You are welome to Cite these tutorials in your research or slides etc. Please don't forget to mention the reference of website. Copy Paste of text is strcitly forbidden. Images can be reuse because images are protected with watermark.

Leave a Reply

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