How can get first record from mySQL table?

manojkumarmaithil's Avatar, Join Date: Jun 2007
Go4Expert Member
PHP Code:
<?php 
$db 
mysql_connect("MySQLHOST""u70001653""8154f5");
mysql_select_db("d60001233",$db);

$query  "SELECT * FROM newuser ORDER BY entrydate";
$sql_query =mysql_query($query,$db);
$row=mysql_fetch_array($sql_query);
?>
<?   
<table>
while($row = mysql_fetch_array($sql_query, MYSQL_ASSOC))
    {
 ?>
<tr>
<td><? echo $row["fullname</td>
<td><? echo $row["address"];?></td>
<td><? echo $row["admincheck"];?></td>
<td><? echo $row["entrydate"];?></td>
</tr>
<? 
}
?>
</table>
When we run this code then it produce list form second record. How can I get first record from Table?

Any Idea!

Last edited by shabbir; 11Jan2008 at 19:26.. Reason: Code block
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Still you don't seem to get how to Post a Query as a thread and submit an article. You have submitted the above thread as an article and I have moved it to the forum.
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Code: SQL
SELECT * FROM newuser ORDER BY entrydate LIMIT 1

You may also use "SELECT * FROM newuser ORDER BY entrydate" but use if() instead of while()
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
The problem is you are executing the statement mysql_fetch_array twice before printing the result for the first time and so its getting from the record number 2