Ask about general coding issues or problems here.
Moderators: macek, egami, gesf
by AZDJedi » Tue Nov 20, 2012 1:51 pm
Hi,
I can't seem to figure out, or Google an answer as to why the my code produces the following:
- Code: Select all
$this->db->connect();
$this->db->query("SELECT Friend FROM `customer-friend` WHERE CustomerID=$customerID");
$result = array();
while ( $row = $this->db->nextRecord() ) {
array_push($result, $row);
}
$this->db->disconnect();
The output is as follows
- Code: Select all
Array
(
[0] => Array
(
[0] => 1
[Friend] => 1
)
[1] => Array
(
[0] => 92
[Friend] => 92
)
[2] => Array
(
[0] => 99
[Friend] => 99
)
)
My question is why does it duplicate the values for each element?
-
AZDJedi
- New php-forum User

-
- Posts: 3
- Joined: Fri Mar 16, 2012 9:20 am
by simplypixie » Tue Nov 20, 2012 11:53 pm
Try changing this
- Code: Select all
while ( $row = $this->db->nextRecord() ) {
array_push($result, $row);
}
To this
- Code: Select all
while ( $row = $this->db->nextRecord() ) {
$result[] = $row;
}
-

simplypixie
- php-forum Active User

-
- Posts: 289
- Joined: Sun Dec 11, 2011 12:51 am
- Location: Shrewsbury, Shropshire
-
Return to PHP coding => General
Who is online
Users browsing this forum: pbs and 3 guests