Jump to content

missing last row of my query


carlfaulkner

Recommended Posts

i am trying to select all breeds from table breed and display results. I dont want any duplicate rows.I have table breeds :- breed name, breed id, userid. $query_breeds = "SELECT DISTINCT breedname FROM breeds WHERE userid='$user_id' GROUP BY breedname ORDER BY breedname asc";$result_breeds = mysql_query($query_breeds);$numrows_breeds = mysql_fetch_row($result_breeds); if ($numrows_breeds < 1){some kind of error}else{ while ($row_breeds= mysql_fetch_array($result_breeds)){ echo $row_breeds['breedname'].", "; } } Its possible that some users have 2 or more of the same breed so i only want to list breeds once.

Link to comment
Share on other sites

If you're trying to get the number of rows use mysql_num_rows. When you use mysql_fetch_row or mysql_fetch_array it gets the first (or next) row and moves on. The first time you use that you lose the first row, so that in the while loop you start on the second row.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...