[b]code[/b]
$testResult=mysql_query("select id, name from myTable order by id ") ;
while($row = mysql_fetch_array($testResult))
{
$myRecord="(". $row['id'].")".$row['name']." <br>";
echo $myRecord;
}
[b]result[/b]
[COLOR="#0000CD"](id) name[/COLOR]
(1) Tom
(2) Mary
(3) Jane
(4) Jack
The code above produces the result above.
I like to get the same result above by using one variable named “myWholeResult”.
The code below which is one of trial for it doesn’t work correctly, but I hope it shows what I want.
[b]trial code[/b]
$testResult=mysql_query("select id, name from myTable order by id ") ;
[COLOR="#FF0000"]$myWholeResult[/COLOR] = while($row = mysql_fetch_array($testResult))
{
$myRecord="(". $row['id'].")".$row['name']." <br>";
echo $myRecord;
};
echo [COLOR="#FF0000"]$myWholeResult[/COLOR];
[b]target result[/b]
(1) Tom
(2) Mary
(3) Jane
(4) Jack