javascript - Searching a table row for specific text in a COLUMN and HIGHLIGHT -
i retrieve information database , create table. have column name status , of values equal 'a'. there values though equal 'c'. want rows column of status equal 'c' background color red.
my code doesn't seem work , think javascript part.
any welcome.
my code this:
<thead> <tr> <th>dongle</th> <th>actdate</th> <th>moddate</th> <th>client</th> <th>company</th> <th>activation</th> <th>comments</th> <th>status</th> </tr> </thead> <script type="text/javascript"> $(document).ready(function(){ $('table tr').each(function(){ if($(this).find('td').eq(3).text() == 'c'){ $(this).css('background','red'); } }); }); </script> <?php $querystring = $_session['clientid']; $server = "212.50.99.130\sqlexpress"; $user = "sa"; $password = "sql"; $database = "licenses"; $connectioninfo = array( "database"=>$database,"uid"=>$user, "pwd"=>$password); $link = sqlsrv_connect($server, $connectioninfo); if ($link === false) { echo "connection failed. \n"; die(print_r(sqlsrv_errors(), true)); } $reseller = $_session["seller"]; $strsqlsel= "select dongle dongle, actdate actdate, moddate moddate, client client, company company, activation activation, comments comments, status status licenses reseller = '$reseller' group dongle,actdate,moddate,client,company,activation,comments,status"; $result = sqlsrv_query($link,$strsqlsel); while ($row = sqlsrv_fetch_array($result,sqlsrv_fetch_assoc)){ ?> <tbody> <tr> <td><p><?php echo $row['dongle']; ?></p></td> <td><p><?php echo date_format($row['actdate'],'y-m-d'); ?></p></td> <td><p><?php echo date_format($row['moddate'],'y-m-d'); ?></p></td> <td><p><?php echo $row['client']; ?></p></td> <td><p><?php echo $row['company']; ?></p></td> <td><p><?php echo $row['activation']; ?></p></td> <td><p><?php echo $row['comments']; ?></p></td> <td><p><?php echo $row['status']; ?></p></td> </tr> <?php } ?> </tbody> </table>
css:
tr.red-status {background-color: red;}
php template, table tbody:
<tbody> <?php $result = sqlsrv_query($link, $strsqlsel); while ($row = sqlsrv_fetch_array($result, sqlsrv_fetch_assoc)) : ?> <tr class="<?php echo ($row['status'] == 'c') ? 'red-status' : '' ?>"> <td><p><?php echo $row['dongle']; ?></p></td> <td><p><?php echo date_format($row['actdate'],'y-m-d'); ?></p></td> <td><p><?php echo date_format($row['moddate'],'y-m-d'); ?></p></td> <td><p><?php echo $row['client']; ?></p></td> <td><p><?php echo $row['company']; ?></p></td> <td><p><?php echo $row['activation']; ?></p></td> <td><p><?php echo $row['comments']; ?></p></td> <td><p><?php echo $row['status']; ?></p></td> </tr> <?php endwhile; ?> </tbody>
Comments
Post a Comment