Jump to content

Help with Simple Array


Canman2005

Recommended Posts

Hi all

 

I have the following PHP

 

$q = mysql_query("SELECT * FROM `people` WHERE `type` = 1");
while($r = mysql_fetch_array($q))
{
echo $r['product'];
echo "<br>";
}

 

This produces

 

1

3

6

13

 

which works great.

 

But i'm trying to create an array containing those values, so I get something like

 

array(1, 3, 6, 13)

 

How can I achive this?

 

I've tried

 

$q = mysql_query("SELECT * FROM `people` WHERE `type` = 1");
while($r = mysql_fetch_array($q))
{
$ray = $ray. array($r['product'].',');
}

 

but that doesn't seem to work and no matter how I tweak it, it doesn't seem to work.

 

Can anyone help?

 

Thanks very much

 

Dave

Link to comment
https://forums.phpfreaks.com/topic/201312-help-with-simple-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.