The following is the code I use to try and achieve this.
$con=mysqli_connect("localhost:8889","root","root","booksmart_properties");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else{
echo "we connected";
}
// Perform queries
$sql=mysqli_query($con,"SELECT * FROM ListedProperties");
$result=mysqli_fetch_assoc($sql);
echo $result['*'];
mysqli_close($con);
?>
I'm new to php and i'm sure it's something small, I just can't see it.
Use PHP foreach loop like this:
foreach($result as $key => $val)
{
print $val;
}
You are using
$result = mysqli_fetch_assoc($sql);
which will fetch a result row as an associative array
So you can call your result with a key to get a value.
example:
$result['id']
or to get all:
foreach($result as $key => $value)
{
print $value;
}