I am trying to be good and re-write all of my scripts to use mysqli instead of mysql_query & mysql_result etc. I have written the code below, but I am stuck.
Here's an explanation:
while($row = $result->fetch_assoc()){ echo $row['col_1'] ; }
results echo's "ON" or "OFF" based on the settings of another app. I want to assign that result (ON or OFF) to a variable $status. I will then use that to do something else:
if ($status == 'OFF' ) $display_this = 'on.gif' ; if ($status == 'ON' ) $display_this = 'off.gif';
Here is the code I have written so far:
<?php include "database_login.php"; $db = new mysqli('localhost', $username, $password, $database); if($db->connect_errno > 0){ die('Unable to connect to database [' . $db->connect_error . ']'); } $sql = <<<SQL SELECT * FROM `ft_data_18` SQL; if(!$result = $db->query($sql)){ die('There was an error running the query [' . $db->error . ']'); } while($row = $result->fetch_assoc()){ echo $row['col_1'] ; } $db->close(); ?>