Display results skip first line - mySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DanielleDee
Forum Newbie
Posts: 3
Joined: Mon Aug 09, 2004 9:28 am

Display results skip first line - mySQL

Post by DanielleDee »

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi!

When I display the entire results from a database table (mySQL), for some reason the 1st line is left out.  My code is:

Code: Select all

<?php 

include_once ("dbc.php"); 
$sql=@mysql_query ("SELECT * FROM `my_desc`");
$row=mysql_fetch_array($sql);
$num_rows=mysql_num_rows($sql);
  if ($num_rows < 0) 
  {  
  echo "No Results Available";
	} 
while ($display = mysql_fetch_array($sql)) {
$id= $display["id"];
$title= $display["title"];
$status= $display["status"]; 

echo($id);
echo($title);
echo($status);
}
?>
My primary key is set as auto_increment on id.

If there is 3 rows:
1, Title 1, sold
2, Title 2, sold
3, Title 3, bid

then only the rows for Title 2 and Title 3 will display.

Any ideas?

Thanks!


feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Remove this line:

Code: Select all

$row=mysql_fetch_array($sql);
Doesn't seem to have a purpose anyway.
Post Reply