Simple code that i use to get array results:
require_once 'connect_to_mysql.php';
$sql = "SELECT * FROM protect";
$result = mysqli_query($conn, $sql);
$db_array = array();
if (mysqli_num_rows($result) > 0){
while ($row = mysqli_fetch_assoc($result)){
$db_array[] = $row;
}
}
echo '<pre>';
print_r($db_array);
echo '</pre>';
I get the following array from database:
Array
(
[0] => Array
(
[id] => 1
[words] => cat
[keyword] => nice cat
)
[1] => Array
(
[id] => 2
[words] => good dog
[keyword] => dog training
)
[2] => Array
(
[id] => 3
[words] => love birds
[keyword] => birds
)
)
i wish to get this all data in a single array like this:
Array
(
[0] => cat
[1] => good dog
[2] => love birds
)
Could you please tell how i can do so? Thank you.
wordsto your array here:$db_array[] = $row;?!