Frage

It's friday, so I am obviously not seeing things strait so I thought to ask here.

I want to get a list of names from the database using:

$test = mysql_query("SELECT Names FROM Content ORDER BY Names");

This should give JimMikePeter (at least it does in PHP MyAdmin)

This is not very readable so I thought, lets implode:

$line = implode( ", ", $test);
echo $line;

This should give: Jim, Mike, Peter but it doesn't, it gives: Warning: implode() [function.implode]: Invalid arguments passed

Also I want the result like this: "Jim", "Mike", "Peter" (with quotes)

Any thoughts?

War es hilfreich?

Lösung

You have to fetch the array using mysql_fetch_array. Using a query as a parameter in implode() will give you an error

Andere Tipps

You should know that mysql_query returns a resource documented in the PHP manual you nead to fetch the data with a fetch function like mysql_fetch_array

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top