How can i convert mysql results (from mysql_fetch_array) into such a form?
$some = array(
"comments" => array(
array( "text" => "hi", "id" => "1" ),
array( "text" => "hi", "id" => "2" ),
array( "text" => "hi", "id" => "3" ),
array( "text" => "hi", "id" => "4" )
)
);
while the db looks like:
comments
id text
1 blabla bla
2 bla bla
i’ve tried to fetch the values with foreach/while and insert it into two arrays but no
success…
$some = array(
"comments" => array()
);
$q = $mysql->sf('*', TBL_QST);
foreach($mysql->fetch($q) as $row) {
$some[] = $row;
// $some["comments"][] = $row;
}
My print_r gives:
And the php I did for it is:
I hope this will be to any help and that I didn’t misunderstood your question.