In this article we shall learn how to show records from mysql table. After including the connection file we shall run a sql query which helps in mapping and connecting both the users and the other table in this tutorial the other table is myrecords.
$sql=”select m.*,u.name from myrecords m, users u where m.user_id=u.user_id “;
Now using the function ‘mysqli_query($conn,$sql)’ across the row using another variable row set ($rs) and also pass connection file and sql query as its arguments.
Another function is passed ‘mysqli_num_rows($rs)’ with argument as rowset ($rs) which used to count the number of records. Then a loop is across the row and the data stored is displayed.
<?php
include("connectins.php");
$sql="select m.*,u.name from myrecords m, users u where m.user_id=u.user_id ";
$rs=mysqli_query($conn,$sql);
$cnt=mysqli_num_rows($rs);
echo "total number of records: ".$cnt;
echo"<br>";
while($row=mysqli_fetch_array($rs))
{
echo "<br>Title: ".$row['title'];
echo "<br>Start Date: ".$row['startdate'];
echo "<br>End Date: ".$row['enddate'];
echo "<br>Post Date: ".$row['postdate'];
echo “<br><hr>”;
}
?>
Posted By : Rhythm Arya
Comment here