Php İle Table Güncelleme
-
Asp.net da gridview güncelleme çok basit ancak bir projede ufak bir yerde php kullanmam gerekti.
sayfa load olduğunda veritabanındaki satırları çekip satırları oluşturuyorum.
fakat hemen bu tablonun tepesinde select nesnesi var. (combobox) seçilen seçime göre listeyi yeniden güncellemek istiyorum (filtrelemek).
Yardımcı olabilecek var mı?
<div class="d-flex"> <div class="dropdown mr-1"> <select> <?php $sorgu1 = mysqli_query($conn, "SELECT Customer_No FROM Servis GROUP BY Customer_No"); while($row1 = mysqli_fetch_array($sorgu1)) { echo '<option value="'.$row1['Customer_No'].'">'.$row1['Customer_No'].'</option>'; } ?> </select> </div> <div class="btn-group"> <form action="" method="POST"> <input type="submit" name="button1" value="Query" /> </div> </div> <?php if(isset($_POST['button1'])){ echo("click işlemi"); } ?> <table class="table table-striped table-dark table-sm"> <thead class="thead-dark"> <tr> <th scope="col">#</th> <th scope="col">IP</th> <th scope="col">Licence</th> <th scope="col">Customer</th> <th scope="col">Serial</th> <th scope="col">Company</th> <th scope="col">Date</th> <th scope="col">Version</th> </tr> </thead> <tbody> <?php $sql="SELECT * FROM Servis order by id desc"; $sorgu=mysqli_query($conn, $sql); while( $sonuc=mysqli_fetch_row($sorgu) ){ echo "<tr>"; echo "<th scope='row'>$sonuc[0] </th>"; echo "<td>$sonuc[1]</td>"; echo "<td>$sonuc[2]</td>"; echo "<td>$sonuc[3]</td>"; echo "<td>$sonuc[4]</td>"; echo "<td>$sonuc[5]</td>"; echo "<td>$sonuc[6]</td>"; echo "<td>$sonuc[7]</td>"; echo "</tr>"; } ?>
Asayisci tarafından 02/Nis/20 17:11 tarihinde düzenlenmiştir -
Php ile bu tür işlemler için datatable kullanılıyor. Php serverside datatable diye arama yaparsanız kaynaklar çıkar hocam.
-
<div class="d-flex"> <div class="dropdown mr-1"> <select name="customer"> <?php $sorgu1 = mysqli_query($conn, "SELECT Customer_No FROM Servis GROUP BY Customer_No"); while($row1 = mysqli_fetch_array($sorgu1)) { echo '<option value="'.$row1['Customer_No'].'">'.$row1['Customer_No'].'</option>'; } ?> </select> </div> <div class="btn-group"> <form action="" method="POST"> <input type="submit" name="button1" value="Query" /> </div> </div> <table class="table table-striped table-dark table-sm"> <thead class="thead-dark"> <tr> <th scope="col">#</th> <th scope="col">IP</th> <th scope="col">Licence</th> <th scope="col">Customer</th> <th scope="col">Serial</th> <th scope="col">Company</th> <th scope="col">Date</th> <th scope="col">Version</th> </tr> </thead> <tbody> <?php if(isset($_POST['customer']) and (int)($_POST['customer'])>0){ $sql="SELECT * FROM Servis where Customer_No=".(int)($_POST['customer'])." order by id desc"; }else{ $sql="SELECT * FROM Servis order by id desc"; } $sorgu=mysqli_query($conn, $sql); while( $sonuc=mysqli_fetch_row($sorgu) ){ echo "<tr>"; echo "<th scope='row'>$sonuc[0] </th>"; echo "<td>$sonuc[1]</td>"; echo "<td>$sonuc[2]</td>"; echo "<td>$sonuc[3]</td>"; echo "<td>$sonuc[4]</td>"; echo "<td>$sonuc[5]</td>"; echo "<td>$sonuc[6]</td>"; echo "<td>$sonuc[7]</td>"; echo "</tr>"; } ?>
Böyle denermisin.
ama şu aşağıdaki satırı böyle kullanmak yanlış
$sql="SELECT * FROM Servis where Customer_No=".(int)($_POST['customer'])." order by id desc";
aşağıdakini inceleyebilirsin
https://www.w3schools.com/php/php_mysql_prepared_statements.asp