How can I assign query result into array elements?
This is my code:
include('db.php');
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Database connection error");
mysql_select_db($dbname);
$query = "select * from test where value=20";
$result = mysql_query($query);
$vegetable_list = array('$rice', '$wheat', '$potato', '$pulses');
$i = 1;
while($row_result = mysql_fetch_row($result))
{
??????? = $row_result[$i];
$i++;
}
How can I assign the query result into the array? Let's say:
$rice = $row_result[1];
$wheat = $row_result[2];
$potato = $row_result[3];
How I can assign the values automatically?