Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing first record in PHP / MySQL page

Status
Not open for further replies.

crighton

Programmer
Aug 31, 2001
7
ES
Hi,

I'm not sure if the following is a MySQL or PHP issue but would appreciate all advice.

I have a page where a list of names are to be displayed. I present the user the option of choosing the sort order using links of the letters A-Z but also the option to show all names on the same page.

I thought it was working fine but have just realised that in each case the very first record is missing from any choice. So, for example if the user clicks "A" the first name displayed should be Adami, Valerio followed by Adela, R.D. etc. In fact the first name is skipped and all names from the second onwards print fine. This happens with all choices A-Z and with the show all option (in this case Adami is the only record skipped as he is the first).

The page can be viewed here (with code extracts included below):


Can anyone can shed any light as to where this error is being caused and how it might be fixed?

Many thanks,

Gary Crighton

CODE EXTRACTS:

My sort links takes the following form:

<a href=&quot;<?PHP $PHP_SELF ?>?lang=<?PHP echo $lang ?>&sort=a&quot;>A</a>


My select statement:

if ($sort == &quot;all&quot;) {
$result = mysql_query (&quot;SELECT * FROM biografias WHERE Tipo = 1 ORDER BY nombre&quot;);
} else {
$result = mysql_query (&quot;SELECT * FROM biografias WHERE Tipo = 1 AND LOWER(SUBSTRING(nombre,1,1)) = '$sort' ORDER BY nombre&quot;);
}


Printout statements as follows:

<?
if ($row = mysql_fetch_array($result) == &quot;&quot;) {
?>

Etc...

<?
} else {
while ($row = mysql_fetch_array($result)) {
?>

<tr><td class='list'>
<a href='/production/artistas/artistas_detalle.php?lang=<?PHP echo $lang ?>&ID=<?PHP echo $row[&quot;ID&quot;]?>'><?PHP echo $row[&quot;Nombre&quot;]?></a>
</td></tr>

?>

Etc...
 
one of these should be set to 0 AND LOWER(SUBSTRING(nombre,1,1)) as mysql results are returned as the first result being 0 not 1 ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top