PHP: insert query result into array elements

RonnyGeeks

New Member
How can I assign query result into array elements? This is my code:\[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=http://stackoverflow.com/questions/3861001/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++;}\[/code\]How can I assign the query result into the array? Let's say:\[code\]$rice = $row_result[1];$wheat = $row_result[2];$potato = $row_result[3];\[/code\]How I can assign the values automatically?
 
Back
Top