2017-12-22 3 views
0

Ich hole Daten in einer Tabelle aus der Datenbank, und es gibt drei Schaltflächen aktualisieren, löschen und aktiv/inaktiv Schaltfläche ,, alle drei haben ihre eigenen Funktionalitäten, aber nach dem Ereignis hat es um die aktualisierten Daten in der Tabelle neu zu laden. Ich bin in der Lage, ganze Seite neu zu laden, aber ich möchte nur den Inhalt der Tabelle neu laden, ich habe weniger Kenntnisse über Javascript und Ajax .. Ich bekomme keine richtige Möglichkeit, mit Ajax fortzufahren .. Bitte helfen Sie mir mit jedem Verfahren, das kann kann mein Problem lösen .. Wie richtig kann ich in meinen Code integrieren.Reload Tabelle ohne Aktualisierung der ganzen Seite in 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>

mit echo "<meta http-equiv='refresh' content='0'>"; diese Zeile Code ich in der Lage bin ganze Seite zu aktualisieren ,, bitte helfen, wie kann ich nur Tabelle nachladen

+0

Vielen Dank Herr, ,, plz helfen Sie mir mit einem weiteren Zweifel, Ist es möglich, meine Tabelle nach diesen Ereignissen zu aktualisieren ???? so dass ich sicher sein werde, dass ich in der richtigen Weise gehe –

+1

Tun Sie etwas Forschung auf Datatable, die Ihre Anforderungen erfüllen wird. –

+0

danke dir, sicher, ich werde daran arbeiten –

Antwort

1

Sie kein bestimmtes HTML-Element nachladen kann mit ein serverseitiges Skript

Sie müssen auf AJAX erforschen, die genau das tun können, was Sie wollen.

Verwandte Themen