php - How to highlight a row of my table -
how can highlight background color of row of table print way when read it's contents database? 2 rows. condition highlight value of 3rd column.
<?php echo "<table id='allocation' class='inlinetable'>"; //style='border: solid 1px black;' echo "<tr>"; echo "<th class=\"row-1 a_user\">user </th>"; echo "<th class=\"row-2 a_destination\">user </th>"; echo "<th class=\"row-3 a_tremaining\">time remaining </th>"; echo "<col = width: 3em />"; echo "</tr>"; echo "<col = width: 3em />"; class tablerows extends recursiveiteratoriterator { function __construct($it) { parent::__construct($it, self::leaves_only); } function current() { return "<td style='width: 100px; border: 1px solid black;'>" . parent::current(). "</td>"; } function beginchildren() { echo "<tr>"; } function endchildren() { echo "</tr>" . "\n"; } } $servername = "localhost"; $dbname = "mydb"; $user = 'root'; $port = 3306; try{ $conn = new pdo("mysql:host=$servername;port=$port;dbname=$dbname", $user); $conn->setattribute(pdo::attr_errmode, pdo::errmode_exception); $sql_fetch = $conn->prepare("select user_id, destination, trem reservation_table"); $sql_fetch->execute(); $result = $sql_fetch->setfetchmode(pdo::fetch_assoc); foreach(new tablerows2(new recursivearrayiterator($sql_fetch->fetchall())) $k=>$v) { echo $v; } } catch(pdoexception $e) { echo "error: " . $e->getmessage(); } echo "</table>"; $conn = null; ?> may please seek help? want highlight or blink row when value in trem (third column) reaches 00:00. css right basic/simple : https://jsfiddle.net/8lfj3h0j/
really need help.
since cannot yet comment, going ask way. can please bit more specific. trem value looks counter. want checking value of row javascript, , if value 00.00 change css class javascript.
$('#elementid').toggleclass('yourcssclass'); if not mean means feel free correct me or clarify question:)
edit: in php function "current" can check if value 00.00 if statement. call javascript function if value 00.00 should this:
function current() { if(parent::current()=="00.00"){ echo '<script type="text/javascript">' , '$('#elementid').toggleclass('yourcssclass');' , '</script>' ;}else{} return "<td style='width: 100px; border: 1px solid black;'>" . parent::current(). "</td>"; } note: have little experience recursiveiterator classes can not tell certaincy parent::current()=="00.00" work, should general idea of checking value , calling js function.
edit: copy pasted comment
<?php $i=0; while($array=sqlsrv_fetch_array($data)){ $countervariable=parent::current(); //not sure if above line works theory ?> <tr data-id="<?php echo $i; ?>"> <td><?php echo $array['product_id']; ?></td> <td><?php echo $array['product_name']; ?></td> <td><?php echo $countervariable ?></td> </tr> <?php $i=$i+1; }?>
Comments
Post a Comment