
December 7th, 2012, 09:53 AM
|
|
Contributing User
|
|
Join Date: Jun 2009
Posts: 313
  
Time spent in forums: 3 Days 15 h 8 m 35 sec
Reputation Power: 5
|
|
|
If/then written right?
Howdy y'all. I have the simple if/then in my while loop below. It is to meerly place an 'X' if an item has been paid. If the item HAS been paid, the value retrieved from the db is 1, otherwise 0. When the while loop runs, I get no errors, but every item is being marked with an 'X', even though a 0 (zero) has been return from the db. Am I overlooking something?
PHP Code:
$invoices = mysqli_query($con,"SELECT * FROM `invoices` WHERE MONTH(due) = " . $month . " ORDER BY `due` ASC;");
$category = mysqli_query($con,"SELECT * FROM `category`;");
while($row = mysqli_fetch_assoc($category)) {
$cat[] = $row;
}
PHP Code:
while ($list = mysqli_fetch_assoc($invoices)) {
if($list['paid'] = "1") { $paid = "X"; } else { $paid = ""; }
echo " <tr>
<td align=\"center\">" . $paid . "</td>
<td align=\"center\">" . date('Y-d-m',strtotime($list['due'])) . "</td>
<td align=\"right\">$" . $list['amount'] . "</td>
<td align=\"left\">" . $cat[$list['category']-1]['name'] . "</td>
<td align=\"left\">" . $list['comment'] . "</td>
</tr>\n";
}
Last edited by Triple_Nothing : December 7th, 2012 at 09:55 AM.
|