Re: Loop issues

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

 



Dan Shirah 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?


forgot about that glitch in doing it that way. The reason is because the system will create the new entry in the array in the while loop, but then the call to the fetch fails. So the while loop gets loaded with a result of false rather then an array.

to fix this, you could simply do something like this

if ( $cs_type ) {
    while ( $record = mssql_fetch_array($cs_type) ) {
        $records[] = $record;
    }
}

this would get rid of the empty array entry.

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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