Adam Kona Adam Kona - 1 year ago 78
MySQL Question

How do I output the result from an sql query onto the screen in php

The following is the code I use to try and achieve this.

// Check connection
if (mysqli_connect_errno())
echo "Failed to connect to MySQL: " . mysqli_connect_error();

echo "we connected";

// Perform queries
$sql=mysqli_query($con,"SELECT * FROM ListedProperties");

echo $result['*'];



I'm new to php and i'm sure it's something small, I just can't see it.

Answer Source

Use PHP foreach loop like this:

foreach($result as $key => $val)
     print $val;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download