PHP can't echo an Array, it comes across an Array and then just returns "Array" to let you know it's there. You can do one of two things:
1. Use print_r which means print readable so it will print the array so that you can see the contents.
Take for example the following array:
PHP Code:
<?php
$fruits = array("Banana", "Strawberry", "Tomato") // Yes tomato is a fruit
echo $fruits; // Prints "Array" to the screen, doesn't show the values within it.
// But if we use print_r it will print the following
print_r($fruits);
// Prints : Array ( [0] => Banana [1] => Strawberry [2] => Tomato )
?>
2. Use echo to access an individual item in the array:
PHP Code:
// To access one of these values you need to put an index
echo $fruits[1]; // Will echo Strawberry, remember the first item is at 0
You just need to put $row['something'], depending on which column you want to access.
So something like:
PHP Code:
<?php
$con = mysqli_connect("localhost", "root", "pass");
$query ="SELECT something FROM table";
$result = mysqli_query($query, $con);
while ($row = mysqli_fetch_array($result))
{
echo $row['something'] . "<br />"; // Echos all records within the selected column
}
?>
Bookmarks