Question:
sql data to array php... urgent 10 points.?
touchdown
2013-04-30 06:09:10 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;
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:
anonymous
2013-04-30 06:15:02 UTC
$count = 0;

$array = array();

$mysql_query = $mysqli->query("SELECT equipment FROM your_table");

if($mysql_query->num_rows) {

while($mysql_row = $mysql_query->fetch_assoc()) {

$aray[$count] = $mysql_row['equipment'];

$count++;

}

}
KIRAN KUMAR
2013-04-30 06:15:57 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
henze
2016-10-14 14:10:12 UTC
$information[0]="m600"; $information[a million]="ced11"; $information[2]="fat25"; now to echo an merchandise in this array do right here: echo $information[0]; U could additionally make arrays like this: $information=array("m600","ced11","fat25"); to echo this u ought to apply the comparable approach as pronounced above. be conscious: in case you utilize mysql_fetch_array the products interior the database will automaticly bypass in an array! occasion: $row = mysql_fetch_array(mysql_query(choose * FROM occasion)); echo $row[0];


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Search results for 'sql data to array php... urgent 10 points.?' (Questions and Answers)
3
replies
Sql data to array graph php... urgent 10 points.?
started 2013-04-30 06:55:21 UTC
programming & design
Loading...