Jump to content


Photo

Echoing mysql query in one line


  • Please log in to reply
2 replies to this topic

#1 xero

xero
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 11 October 2006 - 07:26 AM

Hello everyone.
Been looking around this nice site a little now and started to get a hang of things, but i've been bugged with a little something.
I'm trying to show all results from a mysql query in one line.
i.e:

SELECT handle FROM users

A simple querry that will print out all the handles from a table, tryed to loop a little but i'm not shure how to make it show all lines.
How can i extract all of the results easly into a single variable (not array) as a text line?
i.e: $variable = "handle1, handle2, handle3"
Might be only me that aint thinking straight. Hope someone can give me a little boost here :)



#2 TEENFRONT

TEENFRONT
  • Members
  • PipPipPip
  • Advanced Member
  • 338 posts

Posted 11 October 2006 - 09:10 AM

Not entirly sure what you mean mate...

one line?

if it what i think you mean, then a loop should work. so $variable will loop through and show handle1 for the first entry, then handle2 for the second entry etc.
Teenfront.co.uk : Free Teen Chat -  FunkySmileys.co.uk : MSN Smileys -  ArcadeMonkey.co.uk : Free Flash Games
8Baller.co.uk : Free Multiplayer Pool [url=http://8Baller.co.uk]

#3 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 11 October 2006 - 09:19 AM

Something like....

SELECT GROUP_CONCAT(DISTINCT handle SEPARATOR ', ') AS handles FROM users;


me!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users