0
データベースからテーブルのデータを取得していますが、3つのボタンの更新、削除、アクティブ/非アクティブのボタンが3つありますが、それぞれ独自の機能がありますが、更新されたデータをテーブルにリロードする。私は全体のページをリロードすることができますが、私はテーブルの内容だけをリロードしたい、私はJavascriptとajaxについての知識が少ない。私はAjaxを進める適切な方法を得ていない。私の問題を解決することができます..どのように正しく自分のコードに統合することができます。 echo "<meta http-equiv='refresh' content='0'>";
私は、ページ全体を更新することができるよ、このコード行を使用してPHPのページ全体を更新するリロードテーブル
<?php
session_start();
if(empty($_SESSION))
{
header("Location: ../vendor/login.php");
}
$mpage = "printer";
$page = "list_printer.php";
include '../header.php';
?>
<!DOCTYPE html>
<html>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Printer Lists
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li><a href="#">Printer</a></li>
<li class="active">List Printers</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
\t \t <?php
\t
\t
\t //echo session_id();
\t $email1 = $_SESSION['email'];
\t $Vendor_id="SELECT Vendor_id FROM vendors where email = '$email1' ";
\t $result=mysqli_query($conn,$Vendor_id);
\t $row = mysqli_fetch_row($result);
\t \t \t \t \t \t $sql = "SELECT Vendor_pricing_id, status, printer_name,process,material,color,strength,surface_finish,per_gram_charge,per_hour_charge FROM vendor_pricing where Vendors_Vendor_id= $row[0]";
\t \t \t \t \t \t $query = mysqli_query($conn, $sql);
\t \t \t \t \t \t if (!$query) {
\t \t \t \t \t \t \t die ('SQL Error: ' . mysqli_error($conn));
\t \t \t \t \t \t }
\t \t \t \t \t \t
\t \t \t \t
if(isset($_POST['submit'])) {
\t $_SESSION['v_id']=$_POST['v_id'];
$update=$_POST['v_id'];
$p_gram=$_POST['p_gram'];
$p_hour=$_POST['p_hour'];
$qry=mysqli_query($conn,"UPDATE `vendor_pricing` SET `per_hour_charge`='$p_hour',`per_gram_charge`='$p_gram' WHERE `Vendor_pricing_id`='$update'"); \t \t
//echo "<meta http-equiv='refresh' content='0'>";
echo '<script type="text/javascript">';
echo 'setTimeout(function() { swal("Updated!","Successfully!","success");';
echo '}, 200);</script>';
//echo "<meta http-equiv='refresh' content='0'>";
}
if(isset($_POST['delete'])) {
\t $update=$_POST['v_id'];
\t mysqli_query($conn, "UPDATE vendor_pricing SET status = 'inactive' where Vendor_pricing_id=$update");
\t \t echo "<meta http-equiv='refresh' content='0'>";
} \t
if(isset($_POST['link'])) {
\t $update=$_POST['v_id']; $st=$_POST['link'];
\t if($st=="active")
\t { mysqli_query($conn, "UPDATE vendor_pricing SET status = 'inactive' where Vendor_pricing_id=$update");
echo "<meta http-equiv='refresh' content='0'>";}
\t else { mysqli_query($conn, "UPDATE vendor_pricing SET status = 'active' where Vendor_pricing_id=$update");
\t echo "<meta http-equiv='refresh' content='0'>";}
\t
} \t \t \t \t \t
\t \t \t ?>
\t \t
\t \t
<div class="box table-responsive no-padding">
<div class="box-header">
<h3 class="box-title">List of all Printers</h3>
</div>
<!-- /.box-header -->
<div id="response" class="box-body">
\t \t \t
<table id="example1" class="table table-bordered table-striped" >
<thead>
<tr>
<th>ID</th>
<th width="10%">Printer Name</th>
<th>Process</th>
\t \t \t \t \t \t \t \t \t \t \t <th>Material</th>
<th>Color</th>
<th>Strength</th>
<th>Surface Finish</th>
\t \t \t \t \t \t \t \t \t \t \t <th padding>per Gram</th>
<th>per Hour</th>
\t \t \t \t \t \t \t \t \t \t \t <th >Action</th>
</tr>
</thead>
<tbody>
<?php
\t \t
\t \t while ($row = mysqli_fetch_array($query))
\t \t {
\t \t \t $vid=$row['Vendor_pricing_id'];
\t \t \t $p_name=$row['printer_name'];
\t \t \t $pro=$row['process'];
\t \t \t $mat=$row['material'];
\t \t \t $color=$row['color'];
\t \t \t $type=$row['strength'];
\t \t \t $sur=$row['surface_finish'];
\t \t \t $p_gram=$row['per_gram_charge'];
\t \t \t $p_hour=$row['per_hour_charge'];
\t \t \t $st=$row['status']; if ($st=="active"){ $link='inactive';}
\t \t \t \t \t \t else { $link='active';}
\t \t
\t \t \t \t \t \t \t \t \t \t
\t ?>
\t \t \t \t <tr>
\t \t \t \t \t <form method="post">
\t \t \t \t \t <td><?php echo $vid;?>
\t \t \t \t \t <input type="hidden" value="<?php echo $vid;?>" name="v_id">
\t \t \t \t \t </td>
\t \t \t \t \t <td><?php echo $p_name;?></td>
\t \t \t \t \t <td><?php echo $pro;?></td>
\t \t \t \t \t <td><?php echo $mat;?></td>
\t \t \t \t \t <td><?php echo $color;?></td>
\t \t \t \t \t <td><?php echo $type;?></td>
\t \t \t \t \t <td><?php echo $sur;?></td>
\t \t \t \t \t <td style="padding:9px !important; margin:0px !important;" ><input type="text" style="background:none!important; width:45px; border:none !important; border-color:none;" value="<?php echo $p_gram;?>" name="p_gram"></td>
\t \t \t \t \t <td style="padding:9px !important; margin:0px !important;"><input type="text" style="background:none!important; width:45px; border:none !important; border-color:none;" value="<?php echo $p_hour;?>" name="p_hour"></td>
\t \t \t \t \t <td>
\t \t \t \t \t <button type="submit" name="submit" value="submit" class="btn btn-info btn-small">Update</button>
\t \t \t \t \t <button type="link" name="link" value="<?php echo $st;?>" class="btn btn-default btn-warning btn-small" style="color:white" ><?php echo $link;?></button>
<button type="delete" name="delete" value="delete" class="btn btn-default btn-warning btn-small" style="background:#ED5E68; color:white" >Delete</button>
\t \t \t \t \t
\t \t \t \t \t </td>
\t \t \t \t \t
\t \t \t \t \t </tr>
\t \t \t \t \t </form> \t
\t \t \t \t \t <?php
\t \t }
\t \t
\t \t ?>
\t \t
\t \t
</tbody>
</table>
</div>
<!-- /.box-body -->
</div>
<!-- /.box -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php
include '../footer.php';
?>
</html>
,,
ありがとうございました、plzもう一つの疑問を私に教えてください、それらのイベント後に私のテーブルをリフレッシュすることは可能ですか?私は正しい方法で私が行っていることを確認します –
あなたの要件を満たすdatatableに関するいくつかの研究を行うだけです。 –
ありがとう、私はそれに取り組むだろう –