Re: Turning result into array from columns

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$realones = $row['id'];

This line needs to be

$realones[] = $row['id'];

...then you will be filling an array instead of just overwriting the same variable repeatedly!

   -Stephen


----- Original Message ----- From: "Dave W" <dabbaking@xxxxxxxxx>
To: "PHP DB" <php-db@xxxxxxxxxxxxx>
Sent: Friday, September 22, 2006 10:35 PM
Subject:  Turning result into array from columns


So I'm trying to pull id's and put them into an array. I know I need to
iterate through them, but it doesn't seem to turn into an array. Here's the
function that I'm trying:

function checkID($id) {
$q = sprintf("SELECT id FROM content");
$result = $this->query($q);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$realones = $row['id'];
}

if(in_array($id,array($realones))) { return true; } else { return false; }
}

It's only grabbing the first row id and putting it into the array. It won't
put any of the other ones in. If I just echo $row['id'], it will show both
of them, just not put both of them into an array.

--
Dave W


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux