Though these questions have already been answered and i have tried to follow those, yet the first row from mysql database is not getting displayed in the table. (I have three rows)
Following is my code. Will be very kind of you if you can help. Thank You.
<?php
require_once 'dbreg.php';
?>
<!DOCTYPE html>
<head>
<title>User Listing</title>
</head>
<body>
<table border="1">
<tr>
<td>Firstname</td>
<td>Lastname</td>
<td>Gender</td>
<td>Address</td>
<td>Country</td>
<td>Actions</td>
</tr>
<?php
$query = mysql_query("SELECT * FROM regform");
if(mysql_fetch_row($query) > 0) {
while ($result = mysql_fetch_assoc($query)) {
?>
<tr>
<td><?php echo $result['firstname'];?></td>
<td><?php echo $result['lastname'];?></td>
<td><?php echo $result['gender'];?></td>
<td><?php echo $result['address'];?></td>
<td><?php echo $result['country'];?></td>
<td><a href="view.php">View</a> /<a href="#"> Edit</a></td>
</tr>
<?php
}
}
?>
</body>
</html>
"if(mysql_fetch_row($query) > 0) {" line is reading already the result-set moving the cursor forward so when code execution gets to the "while ($result = mysql_fetch_assoc($query)) {" line it is already at second row in result-set. You should remove the "if line" because while will act exactly as you expect.