jeudi 25 février 2016

PHP - How Do I Change the Background of a Cell based on Value (sqlite)

<?php

  try

  {

$db = new PDO("sqlite:/var/www/html/mobile_app.db");

print "<table border=1>";
print "<tr><td>Game ID</td><td>Game Name</td><td>Approved Version</td><td>Current Version</td><td>Status</td><td>Date Checked</td><td>Date Changed</td></tr>";
$result = $db->query('SELECT * FROM mobile_version');
foreach($result as $row)
{
  print "<tr><td>".$row['gameid']."</td>";
  print "<td>".$row['game_name']."</td>";
  print "<td>".$row['approved_version']."</td>";
  print "<td>".$row['current_version']."</td>";
  print "<td>".$row['status']."</td>";
  print "<td>".$row['date_checked']."</td>";
  print "<td>".$row['date_changed']."</td>";
}
print "</table>";
$db = NULL;
}
catch(PDOException $e) {
  echo $e->getMessage();
}
?>

My aim is to change just the cell with the data in column 'status'. Red if it equals UNAPPROVED and green if it equals APPROVED. Any help would be awesome! Data is in a single table in an sqlite3 database.

Aucun commentaire:

Enregistrer un commentaire