Question:
Sql data to array graph php... urgent 10 points.?
touchdown
2013-04-30 06:55:21 UTC
i want to put my data in a array php.... so that i can use it to in my graph.. for example:
my data in mysql is
equipment<------colum name
m600
ced11
fat25
---------------
my array will be

$a= m600;
$B = ced11;
$c = fat25;
----------------
and my aray graph will be.......
s_data =($a,$B,$c)

just an example that i want in array. i know it is nnot working.. i want a code answer not explanation. please help me. urgent..
Three answers:
KIRAN KUMAR
2013-04-30 07:01:41 UTC
Hi,

Please use below code for your requirement.

$typeArray = array();

$query = "select equipment from table";

$result = mysql_query($query);



if ($result) {

$i = 0;

while ($record = mysql_fetch_array($results))

{

$typeArray[$i] = $record['equipment'];

$i = $i+1;

}

}



$typeArray will contain your data
Tom
2013-04-30 07:01:27 UTC
$data[0]="m600";

$data[1]="ced11";

$data[2]="fat25";



now to echo an item in this array do the following:



echo $data[0];



U can also make arrays like this:



$data=array("m600","ced11","fat25");



to echo this u must use the same method as mentioned above.







NOTE:



if you use mysql_fetch_array the items in the database will automaticly go in an array!



example:



$row = mysql_fetch_array(mysql_query(SELECT * FROM EXAMPLE));



echo $row[0];
henze
2016-10-14 14:12:00 UTC
hi, Please use under code on your requirement. $typeArray = array(); $question = "choose kit from table"; $result = mysql_query($question); if ($result) { $i = 0; jointly as ($checklist = mysql_fetch_array($outcomes)) { $typeArray[$i] = $checklist['kit']; $i = $i+a million; } } $typeArray will incorporate your information


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...