Jump to content

Archived

This topic is now archived and is closed to further replies.

xero

Echoing mysql query in one line

Recommended Posts

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:

[code]SELECT handle FROM users[/code]

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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Something like....

[code]SELECT GROUP_CONCAT(DISTINCT handle SEPARATOR ', ') AS handles FROM users;[/code]


me!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.