RE: Displaying results from a query properly.

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

 



On 24 March 2006 16:40, Alex Major wrote:

> Thanks, works like a charm (had to make is -2 instead of -1
> as it added a
> space after each result). Hadn't thought of something so simple.
> 
> On 24/3/06 16:22, "Bastien Koert" <bastien_k@xxxxxxxxxxx> wrote:
> 
> > Build it up as a string and remove the trailing comma at the end of
> > the loop 
> > 
> > do { $sHTML .= ''.$administrators['username'].', ';}
> > while ($administrators = mysql_fetch_assoc($administrators_result))
> > 
> > $sHTML = substr($sHTML, 0, strlen($sHTML)-1);

You don't need a strlen() call here, as substr understands "count from the right" notation:

   $sHTML = substr($sHTML, 0, -1);

... or, with Alex's correction:

   $sHTML = substr($sHTML, 0, -2);

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux