Please see the php function below. I am trying to get the results of my query to display as an array in the same format as the static array shown below. How would I replace that static array with results from my query? Thanks in advance.
<?php
$mysqli = new mysqli("xxx", "xxx", "xxx", "xxx");
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s
", $mysqli->connect_error);
exit();
}
$query = "SELECT event_id, event_name FROM events ORDER by event_id";
$result = $mysqli->query($query);
$row = $result->fetch_array(MYSQLI_BOTH);
function get_price($find){
$books=array(
"java"=>266,
"c"=>250,
"php"=>320
);
foreach($books as $book=>$price)
{
if($book==$find)
{
return $price;
break;
}
}
}
?>