how to print database filr

1Tsme1941

Member
Hi folks. please tell me what is wrong with this code.
-----------------------------------------------------
<?php
//Open a new connection to the MySQL server
require_once "getprerentdb.php";

//MySqli Select Query

$results = $mysqli->query("SELECT * FROM waitlist");

echo "<center>";echo date('m/d/y');echo "</center>";
?>
<!DOCTYPE html><html>
<head></head>
<body><center>
<h3>515 Certification Expiration Report: 06/22/2020 - 06/22/2021</h3>

<table border='1' cellpadding="4">
<thead>
<tr>
<th colspan=2></th>
<th>movein</th>
<th>effect</th>
<th>expire</th>
<th>days</th>
<th colspan=3>recertification notification</th>
<tr>
<th>unit#</th>
<th>resident name</th>
<th colspan=3>date</th>
<th>left</th>
<th>90 day</th>
<th>60 day</th>
<th>30 day</th>
</tr>
</thead>
<tbody>

<?php
/* -------------------------------------------------------------- */
while($row = mysqli_fetch_array($results)) {
/* -------------------------------------------------------------- */
?>
<tr>
<td><?php echo $data['unit']; ?></td>
<td><?php echo $data['tenant']; ?></td>
<td><?php echo $data['moveindate']; ?></td>
<td><?php echo $data['effdate']; ?></td>
<td><?php echo $data['expdate']; ?></td>
<td><?php echo $data['daysleft']; ?></td>
<td><?php echo $data['90date']; ?></td>
<td><?php echo $data['60date']; ?></td>
<td><?php echo $data['30date']; ?></td>
<td><?php echo $data['late']; ?></td>
<td><?php echo $data['comments']; ?></td>
<td><?php echo $data['paidsum']; ?></td>
</tr>
<?php
}
?>

</tbody></table></center></body></html>

----------------------------------------------------------
result:
03/15/21
515 Certification Expiration Report: 06/22/2020 - 06/22/2021

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\property\certlog.php on line 39
movein effect expire days recertification notification
unit# resident name date left 90 day 60 day 30 day
 

1Tsme1941

Member

Cromewell, I've been bouncing around thid issue for weeks. I'm slow but haven't discovered the use of "$mysqli->error}".​

I don'f understand why this same code works great in 3 other programs but not this one. How do I state $mysqli->error here?
 

Cromewell

Administrator
Staff member
It is a string that gets set if something goes wrong. Because your query result is false, you know something went wrong.
Code:
if (! $result) {
  echo $mysqli->error;
}
There does not appear to be anything wrong with the query itself.
 

1Tsme1941

Member
thanks, just what I wanted, although , as u said, it wasn't the query. I had an issue w/the table. thanks again. this is solved. Soon
 
Top