문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top