如何在没有提交按钮的情况下将选项的值设置为变量?

时间:2018-09-22 08:36:47

标签: javascript php jquery

我正在分页, 我创建了一个表,其中初始限制为5,这将在页面中显示5个表行,我创建了一个下拉列表,其中提供了五个选项以选择5,10,15,20,25个选项。现在我想根据选择选项显示表行数据,例如,如果我选择5,则数据仅显示5行,如果我选择10,则表显示10行数据,对于25同样。 我有预定义的极限值5,但是如何在没有提交按钮的情况下将选项的值设置到该极限变量中呢?

 <?php
    $sql12 = "SELECT numbers FROM pagenumber";
$result12 = mysqli_query($conn,$sql12);

echo "<select name='username'>";
while ($row12 = mysqli_fetch_array($result12)) {
    echo "<option value='" . $row12['numbers'] ."'>" . $row12['numbers'] ."</option>";
}
echo "</select>";

  $limit = 5;  
if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };  
$start_from = ($page-1) * $limit; 

$sql="SELECT * FROM invoice_details WHERE userid='$userid' ORDER BY invoice_no DESC LIMIT $start_from, $limit";
$result=mysqli_query($conn,$sql);
$row=mysqli_num_rows($result);
$table_data = '';
if($result){

    while($row = mysqli_fetch_assoc($result)){

        $invoice_no                = $row['invoice_no'];
        $customer_id   = $row['customer_id'];
        $start_date          = $row['start_date'];
        $end_date         = $row['end_date'];
        $paystatus              = $row['paystatus']; 
        $mobile = $row['mobile'];
        $email = $row['email'];
        $datee = $row['datee'];
        $subtotal = $row['subtotal'];
        $grandtotal = $row['grandtotal'];
        $modeofpayment = $row['modeofpayment'];
        $discription = $row['discription'];
        $sac = $row['sac'];

        $table_data .= '<tr id="tr_'.$invoice_no.'" ><td>'.$invoice_no.'</td><td>'.$customer_id.'</td><td>'.$start_date.'</td><td>'.$end_date.'</td><td>'.$grandtotal.'</td><td>'.$paystatus.'</td><td>'.$modeofpayment.'</td><td><a target="_blank" href="viewcustomerdetailinvoice.php?invoice_no='.$invoice_no.'"><button type="button" class="btn btn-primary" ><i class="fa fa-user"></i></button></a></td></tr>';

    }
}


?>

0 个答案:

没有答案