Re: Loop issues
| From: | Philip Thompson | Date: | Mon, 19 Nov 2007 18:26:49 +0000 |
| Subject: | Re: Loop issues | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264788@lists.php.net to get a copy of this message | ||
On Nov 19, 2007 12:16 PM, Dan Shirah <mrsquash2@gmail.com> wrote:
> Jim,
>
> I used your suggestion and modified it a little bit. All of the names are
> pulled from the database, but for some reason once it has pulled all the
> names form each query it is adding an empty result to the end.
>
> So when I do a echo $row['first_name']."
> ".$row['last_name']."<br />\n";
> it
> is returning something like this:
>
> John Smith
> Bob Smith
>
> Jane Smith
> Robert Smith
>
> The gap between the names contains a single space " ". I tried to trim
> the
> results but cannot get rid of it.
>
> Any ideas?
Run a test condition before displaying:
<?php
$first = trim ($row['first_name']);
$last = trim ($row['last_name']);
if (!empty ($first) && !empty ($last))
echo "$first $last<br/>\n";
...
?>
HTH
~Philip