How to echo results of database query? [migrated]

I have written some code to access my database and echo the results onto the webpage. Unfortuantely, I must have something wrong in my code. Thank you so much for any assistance.

$conn = new mysqli(“website.com”,”Ericjs”,”Password”,”i4706992_wp1″);
if ($conn) {
echo “Connection established! <br>”;
} else {
die(“Connection failed. Reason: “.mysqli_connect_error());
}
echo “Eric, I’m here first <br>”;
$sql=”SELECT Facility Name, Address, City, State, Zip FROM ‘wp_facilities’
WHERE ‘Zip’ = ‘01040’ LIMIT 50″;
echo “Eric, I’m here second <br>”;
$results=mysqli_query($conn,$sql);
echo “Eric, I’m here third <br>”;
if (mysqli_num_rows($results)>0) {
while($row=mysqli_fetch_array($results)) {
echo “Let’s get ready to roll! <br>”;
echo $row[1].” “.$row[2].” “.$row[3].” “.$row[4].” “.$row[5];
echo “<br>”;
}
}
mysqli_close($conn);

The output I get are the echoes prior to the if statement above.

Connection established!
Eric, I’m here first
Eric, I’m here second
Eric, I’m here third

I was looking for the results to be displayed as:

“Ryan Rink” “524 Pleasant St” “Watertown” “Massachusetts” “01040”

Read more here:: How to echo results of database query? [migrated]

Leave a Reply

Your email address will not be published. Required fields are marked *