Forum Moderators: coopster

Message Too Old, No Replies

extra blank result being returned each time

blank entry always returned from dB query

         

knotworking

9:40 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



I pieced this script together but, it's returning an extra blank result at the end of each search. I know nothing about turnary operators (I think that's what it is and hopefully how you spell it).

Can anybody see what might be causing the extra blank result in the code below:

$columns = 3;
echo "<TABLE BORDER=\"0\">\n";
for($i = 0; $i < $row; $i++) {
$row = mysql_fetch_array($result);
if($i % $columns == 0) {
//if there is no remainder, we want to start a new row
echo "<TR>\n";
}
echo "<TD><p><a href=\"/member-" . $row['id'] . ".php\">" . $row['id'] . "</a></p><br></TD>\n";
if(($i % $columns) == ($columns - 1) ¦¦ ($i + 1) == $row) {
//if there is a remainder of 1, end the row
//or if there is nothing left in our result set, end the row
echo "</TR>\n";
}
}
echo "</TABLE>\n";
}

Thanks for any feedback!

Rinso

10:00 pm on Jul 31, 2005 (gmt 0)

10+ Year Member



Hi,

it's not a php thing. Remove the <br> and it's fixed.

Good luck,
John

knotworking

1:16 am on Aug 1, 2005 (gmt 0)

10+ Year Member



Thanks for the response, Rinso.

No luck on removing the <BR>. It's still returning a final blank result at the end of any query. When there are no results at all, it sometimes does not return the blank result, other times it does.

I'm at a loss.

Nutter

2:05 am on Aug 1, 2005 (gmt 0)

10+ Year Member



Two thoughts.

I usually use while ($row = mysql_fetch_assoc($row) { } as the loop instead of your for ($i...) { } loop.

Also, is it possible there is a blank record in your recordset?

knotworking

1:27 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



Nope, no blank records. I use it to return members matching a specific city or state and, it always returns no matter what is specified.

No luck initially with replacing it with a while. It's returning an error so, I guess the while needs to be worked in (I just swaped one for the other).

Nutter

10:36 pm on Aug 1, 2005 (gmt 0)

10+ Year Member



What was the error when you tried the while loop?

Try this - [us2.php.net...] - Hopefully that's ok since it's not a personal url :) There's an example for the loop just above the Notes section.