如果复选框中的值大于零,则隐藏行

时间:2017-04-13 19:08:44

标签: php jquery mysql

我有一个表使用来自2个不同数据库中3个不同表的计算字段。我试图使用一个复选框来隐藏计算字段大于零的行或欠钱的学生。我添加了一个值为零的复选框。

<form id="formFilter" name="formFilter" method="post" action="">
  <p>
    <input name="selView" type="checkbox" id="selView" onChange="formFilter.submit()" 
value="0" <?php echo (isset($_POST['selView'])?'checked':'');?> />
    view only students with a balance<br />
  </p>
</form>

我需要评估$ balancez,如果$ balancez大于零,当我点击复选框时,我希望没有数字大于零的学生行隐藏。这样我只能查看欠余额的学生。

<table width="800" border="0" class="TFtable sortable">
  <tr>
    <td scope="row"><strong>Students</strong> (<?php echo $totalRows_Recordset1 ?>)</td>
    <td align="center"><strong>ID</strong></td>
    <td align="center"><strong>Division</strong></td>
    <td align="center"><strong>AP Fee</strong></td>
    <td align="center"><strong>Credit Card Payment</strong></td>
    <td align="center"><strong>Store Payment</strong></td>
    <td align="center"><strong>AP Balance</strong></td>
  </tr>
  <?php do { ?>
    <tr>
      <td scope="row"><a href="student_report.php?recordID=<?php echo $row_Recordset1['ID']; ?>" target="new"><?php echo $row_Recordset1['Student']; ?></a></td>
      <td align="center"><?php echo $row_Recordset1['ID']; ?></td>
      <td align="center"><?php echo $row_Recordset1['Division']; ?></td>
      <td align="center"><?php echo "$".$row_Recordset1['Total']; ?></td>
      <td align="center"><?php



mysql_select_db($database_cc, $cc);
$studentid = $row_Recordset1['ID'];
$query_Recordset_CC = 'SELECT credit_card_activity.Student_ID, SUM(credit_card_activity.CC_Amount) AS total_cc2,  credit_card_activity.Ref_ID, credit_card_activity.Settle_Date FROM credit_card_activity WHERE credit_card_activity.Ref_ID LIKE "AP%" AND credit_card_activity.Student_ID = "'.$studentid.'" GROUP BY credit_card_activity.Student_ID';
$Recordset_CC = mysql_query($query_Recordset_CC, $cc) or die(mysql_error());
$row_Recordset_CC = mysql_fetch_assoc($Recordset_CC);
$totalRows_Recordset_CC = mysql_num_rows($Recordset_CC);
$total_cc =-1*(0+$row_Recordset_CC['total_cc2']);


echo ($total_cc < 0 ? "($".abs($total_cc).")" : "$".$total_cc);


?></td>
      <td align="center"><?php



mysql_select_db($database_cc, $cc);
$studentid = $row_Recordset1['ID'];
$query_Recordset_Store = "SELECT checkout.student_id, SUM(`transaction`.total_amount) AS total_store2 FROM checkout, `transaction`, school_store WHERE `transaction`.activity_id=school_store.Tag AND `transaction`.transaction_id=checkout.transaction_id AND (`transaction`.refund_status='0' OR `transaction`.refund_status='1') AND school_store.Activity LIKE 'AP Fee%' AND checkout.student_id='".$studentid."' AND checkout.payment_type NOT IN ('Cash Refund') GROUP BY checkout.student_id";
$Recordset_Store = mysql_query($query_Recordset_Store, $cc) or die(mysql_error());
$row_Recordset_Store = mysql_fetch_assoc($Recordset_Store);
$totalRows_Recordset_Store = mysql_num_rows($Recordset_Store);
$total_store = -1*(0+$row_Recordset_Store['total_store2']);

echo ($total_store < 0 ? "($".abs($total_store).")" : "$".$total_store);


?></td>
      <td align="center"><?php 
      $ap_fees=$row_Recordset1['Total'];
      $ap_cc=$row_Recordset_CC['total_cc2'];
      $ap_store=$row_Recordset_Store['total_store2'];
      $paid=$ap_cc + $ap_store;
      $balancez=($ap_fees - $paid);
      echo ($balancez < 0 ? "($".$balancez.")" : "$".$balancez);
      ?>
      </td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); 



    ?>
</table>

使我的这项任务变得困难的原因是它不是基于mysql查询而是基于其他查询的计算值($ balancez),所以我不能使用Having。有人可以引导我进入一个jquery,可以评估每行的$ balancez并隐藏或显示行,如果满足复选框的值?我也对任何可以解决这个问题的方法持开放态度。非常感谢。

0 个答案:

没有答案