Jump to content

Array


rashmi_k28

Recommended Posts

hi,

 

I have the code :

 

function getdata(){

$values=array();
for ($i = 0; $i < 4; $i++)
        {
                $value[$i] = array(-1,-1,-1,-1);
        }

$sql = "select * from table1";

        $result = mysql_query($sql);

        while($row = mysql_fetch_array($result)){
                $value[$row[0]][0] = $row[1];
                $value[$row[0]][1] = $row[2];
                $value[$row[0]][2] = $row[3];
                $value[$row[0]][3] = $row[4];
        }

return $values;
}

 

 

When I call the function

 

$data=getdata();

How to take each $value[$row[0]][0] as the separate array

 

 

Link to comment
https://forums.phpfreaks.com/topic/127365-array/
Share on other sites

Hi,

 

When I execute the

$sql statement I get the around 200 values.

 

$sql="select time,field1,field2 from table";

 

 

here I want to copy all the 3 fields into an single array.

When I call the function in another page

I want `time` and `field1` and `field2` as a separate arrays again.

 

How can I do it from a single array.

 

Link to comment
https://forums.phpfreaks.com/topic/127365-array/#findComment-658901
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.