Re: Loop issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Nov 19, 2007 12:16 PM, Dan Shirah <mrsquash2@xxxxxxxxx> 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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux