Im new to web development. I need the array like following
["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]
I tried. But I failed.I connected the database. How can I make it?
my array-code
$count=0;
$sql="SELECT name FROM planet";
$sql_run=mysqli_query($con,$sql);
while($row = mysqli_fetch_assoc($sql_run))
{
$result[] = "'".implode("\'",$row)."'".",";
echo $result[$count++];
}
By using above code, i couldn't get the result what I expected.
"'".implode("\'",$row)."'".",". Anyway, to get what you want, you must do$result[] = '"' . $row['name'] . '"'inside of the while().