PHP Api - Results/Array question

StariyElektrik

New Member
I have been looking around for PHP tutorials and I found a very detailed one that have been useful to me.But now, I have a question. The results showed by the API are stored into a $results array. This is the code (for instance):\[code\]$fetch = mysql_fetch_row($go);$return = Array($fetch[0],$fetch[1]); $results = Array( 'news' => Array ( 'id' => $return[0], 'title' => $return[1] )); \[/code\]My question is.. I want to display the last 10 news.. how do I do this? On normal PHP / mySQL it can be done as:\[code\] while($var = mysql_fetch_array($table)) { echo "do something" }\[/code\]How can I make it so the $results can print multiple results?I have tried like:\[code\]while($var = mysql_fetch_array($table)) { $results = Array( 'news' => Array ( 'id' => $return[0], 'title' => $return[1] )); }\[/code\]But this only shows me one result. If I change the $results .= Array(...) it gives error.What can I do?Thanks!EditMy function to read it doesn't read when I put it the suggested way:\[code\]function write(XMLWriter $xml, $data){ foreach($data as $key => $value){ if(is_array($value)){ $xml->startElement($key); write($xml, $value); $xml->endElement(); continue; } $xml->writeElement($key, $value); } } write($xml, $results);\[/code\]
 
Back
Top