Install this on top of the source code to display errors.
<?php error_reporting( E_ALL ); ?>
Or set display_erros in php.ini as follows:
display_errors = On
error_reporting = E_ALL | E_STRICT
,
<?php
$dbc = mysqli_connect(localhost,root,root,itmyfamily);
$query = "SELECT * FROM itsmyfamily ORDER BY last_name ASC, first_name DESC, date ASC";
$data = mysqli_query($dbc,$query);
while ($row = mysqli_fetch_array($data)) {
$i = 0;
if ($i == 0) {
echo '<strong>First Name:</strong> ' .$row['first_name']. ' <br />';
echo '<strong>Last Name:</strong> ' .$row['last_name']. ' <br />';
echo '<strong>Spouse Name:</strong> ' .$row['spouse_name']. ' <br />';
echo '<strong>Email:</strong> ' .$row['email']. ' <br />';
}
else{
echo 'There is no info in the database';
}
$i++;
}
mysqli_close($dbc);
?>
If you can write it this way, i think you dont even need the $i.
$result = mysql_query("SELECT id, first_name FROM mytable");
if($result){
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("ID: %s Name: %s", $row["id"], $row["first_name"]);
}
}
else
echo 'There is no info in the database';
php mysql_fetch_array http://www.php.net/mysql_fetch_array
. http://webcheatsheet.com/php/loops.php
, , , php 5.5.0. mysqli PDO. PHP.
http://www.php.net/manual/en/mysqli.query.php
http://www.php.net/manual/en/pdo.query.php