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 by using MySQL and without using MySQLi.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<?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> |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php $conn = mysqli_connect('localhost','root','','publisher');?> <html> <body> <table border="1"> <?php $books_query=mysqli_query($conn, "select * from books"); while($books_rows=mysqli_fetch_array($books_query)){ ?> <tr> <td><?php echo $books_rows['BookID'] ; ?></td> <td><?php echo $books_rows['BookTitleAttribute'] ; ?></td> </tr> <?php }?> </table> </body> </html> |