Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   How can get first record from mySQL table? (http://www.go4expert.com/forums/record-mysql-table-t8193/)

manojkumarmaithil 11Jan2008 12:57

How can get first record from mySQL table?
 
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!

shabbir 11Jan2008 19:30

Re: How can get first record from mySQL table?
 
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.

pradeep 13Jan2008 12:05

Re: How can get first record from mySQL table?
 
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()

shabbir 13Jan2008 12:50

Re: How can get first record from mySQL table?
 
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


All times are GMT +5.5. The time now is 10:21.