philip ngu philip ngu - 2 years ago 80
SQL Question

Why i only get 1 row of ans?

while($row = mysql_fetch_array($result))
if (isset($row["name"]) && ($row["name"] != "")){
$contentStr = $row["name"];

This works but not the way i want.
I want to show all the data that i get from.
Example in got 4 data now on database and using \n for the next line to show another data. How to write the format ?

Answer Source

Firstly, remove the break. It is serving no purpose.

Now, I believe what you want to do is obtain all the row["name"] values into one String, namely $contentStr, separated by a newline.

If this is the case, use the following:

$contentStr .= $row["name"] . "\n"

Also, make sure to create an empty $contentStr before the loop.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download