I am trying to get the matched rows from a table and save it in a Global Array so that I can use it in different functions.
But when I do print_r of that array it shows only last row.
Here is my code
function setCampoFeed()
{
echo $sql = "SELECT campofeed.tag,campofeed.registro,campofeed.valor FROM campofeed ".
"INNER JOIN registrofeed ON registrofeed.id = campofeed.registro ".
"WHERE registrofeed.feed='".$this->idFeed."'";
$result= $this->localDb->execute($sql);
$this->campoFeed= mysql_fetch_array($result))
}
So here campoFeed is the array that should have all the rows of the match, but now its just having the last row.
Thanks in advance
while($row= mysql_fetch_array($result)) { $this->campoFeed[]=$row; }$this->campoFeedor$this->campoFeed[]can actually push data into array. I would suggest setup a array like$resultArray = array();. When inside while loop,$resultArray[] = $row;. Finally$this->compoFeed = $resultArray;.$this->campoFeed[]works, you can usewhile($row = mysql_fetch_array($result)) { $this->campoFeed[] = $row; }instead of creating a new array.