<td bgcolor="aabbcc"><center>Line 1</td>
<?php
//Connect to mysql server
$con = mysqli_connect('localhost', 'User', 'Pass', 'Database');
if (!$con) {
die ("connection error". mysqli_connect_error());
}
$sql = " SELECT * FROM PMAsset where LineNum ='1' ORDER BY LineNum, AssetNum";
$result = mysqli_query($con, $sql) or die(mysqli_error($con));
$count = 0;
while($row = mysqli_fetch_array($results)) {
?>
<td Bgcolor=<?php echo $row['PMStatus']?>><?php echo $row['AssetNum']?></td>;
<?php
$count++;
}
while ($count++ < 10) {
echo '<td />';
}
?>
What I'm trying to do is create he table based on the sql data and populate the cells the error I get now is
[08-Aug-2017 13:55:01 America/New_York] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given on line 42
Line 41-43:
while($row = mysqli_fetch_array($results)) {
?>
<td Bgcolor=<?php echo $row['PMStatus']?>><?php echo $row['AssetNum']?></td>;
When it runs it should pull from the database and change the td bgcolor to what ever is in the database and show the assetnum as text in the cell. if there is no record then the td bgcolor should be black. for the remaining columns. I think I'm close but I know I'm off a bit too. sugestions?
Aucun commentaire:
Enregistrer un commentaire