-5
A
回答
1
// Insert location of wp-load.php
require("/var/www/yourdomain.com/htdocs/wp-load.php");
// Insert function to get db connection environment
function db_connect()
{
$mydb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
return $mydb;
}
// Sql Query
$sql="UPDATE inscription SET ".$_POST["name"]." = '".$_POST["value"]."'WHERE id = '".$_POST["pk"]."'";
$result_insert = db_connect()->get_results($sql);
+0
非常感謝Punit Patel的答案,但仍然是與我同樣的問題。 – ab2info
-1
這是我的網頁,我有AJAX和jQuery
<?php /* Template Name: fetch presence*/
$today = getdate();
$y = $today['year'];
$today = getdate();
$y = $today['year'];
?>
<!DOCTYPE html>
<html>
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.1/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.1/bootstrap3-editable/js/bootstrap-editable.js"></script>
<style>
.btn-a{
display: flex; justify-content: center;
margin-top: 20px;
}
.img{
display: flex; justify-content: center;
}
.btn-group .button {
background-color:#f44336; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
cursor: pointer;
float: top;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}
.btn-group .button:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<div class="img"><img src="http://localhost/wordpress/wp-content/uploads/2017/04/calender.png" height="117px"></div>
<header class="btn-a">
<div class="btn-group">
<button class="button" Onclick="parent.location='Seminaire1.php'">Seminaire 1</button>
<button class="button" Onclick="parent.location='Seminaire2.php'">Seminaire 2</button>
<button class="button" Onclick="parent.location='Seminaire3.php'">Seminaire 3</button>
<button class="button" Onclick="parent.location='Seminaire4.php'">Seminaire 4</button>
</div>
</header>
<div class="container">
<h1 align="center">Feuille de Présence Seminaire 2: Promotion <?php echo $y;?></h1>
</br>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th width="2%" >Id</th>
<th width="10%" >Cin</th>
<th width="10%">Nom</th>
<th width="10%">Prenom</th>
<th width="10%">Spécialité</th>
<th width="10%">Presnece</th>
<th width="10%">Presnece</th>
<th width="10%">Presnece</th>
</tr>
</thead>
<tbody id="employee_data">
</tbody>
</table>
</body>
</html>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
function fetch_employee_data()
{
$.ajax({
url:"http://localhost/wordpress/fetch",
method:"POST",
dataType:"json",
success:function(data)
{
for(var count=0; count<data.length; count++)
{
var html_data = '<tr><td>'+data[count].id+'</td>';
html_data += '<td data-name="cin" class="cin" data-type="text" data-pk="'+data[count].id+'">'+data[count].cin+'</td>';
html_data += '<td data-name="nom" class="nom" data-type="text" data-pk="'+data[count].id+'">'+data[count].nom+'</td>';
html_data += '<td data-name="prenom" class="prenom" data-type="text" data-pk="'+data[count].id+'">'+data[count].prenom+'</td>';
html_data += '<td data-name="Specialite" class="Specialite" data-type="select" data-pk="'+data[count].id+'">'+data[count].Specialite+'</td>';
html_data += '<td data-name="Presnecea" class="Presnecea" data-type="select" data-pk="'+data[count].id+'">'+data[count].Presnece+'</td>';
html_data += '<td data-name="Presneceb" class="Presneceb" data-type="select" data-pk="'+data[count].id+'">'+data[count].Presnece+'</td>';
html_data += '<td data-name="Presnecec" class="Presnecec" data-type="select" data-pk="'+data[count].id+'">'+data[count].Presnece+'</td>';
$('#employee_data').append(html_data);
}
}
});
}
fetch_employee_data();
$('#employee_data').editable({
container: 'body',
selector: 'td.cin',
url: "http://localhost/wordpress/update",
title: 'Cin Employee',
type: "POST",
//dataType: 'json',
validate: function(value){
if($.trim(value) == '')
{
return 'Ce Champ Est Obligatoire';
}
}
});
$('#employee_data').editable({
container: 'body',
selector: 'td.nom',
url: "http://localhost/wordpress/update",
title: 'Nom Employee',
type: "POST",
//dataType: 'json',
validate: function(value){
if($.trim(value) == '')
{
return 'Ce Champ Est Obligatoire';
}
}
});
$('#employee_data').editable({
container: 'body',
selector: 'td.prenom',
url: "http://localhost/wordpress/update",
title: 'Prenom Employee',
type: "POST",
//dataType: 'json',
validate: function(value){
if($.trim(value) == '')
{
return 'Ce Champ Est Obligatoire';
}
}
});
$('#employee_data').editable({
container: 'body',
selector: 'td.Specialite',
url: "http://localhost/wordpress/update",
title: 'Specialite',
type: "POST",
dataType: 'json',
source: [{value: "redaction medicale", text: "redaction medicale"}, {value: "epidemologie et recherche clinique", text: "epidemologie et recherche clinique"}],
validate: function(value){
if($.trim(value) == '')
{
return 'Ce Champ Est Obligatoire';
}
}
});
$('#employee_data').editable({
container: 'body',
selector: 'td.Presnecea',
url: "http://localhost/wordpress/update",
title: 'Presnecea',
type: "POST",
dataType: 'json',
source: [{value: "Non", text: "Non"}, {value: "Oui", text: "Oui"}],
validate: function(value){
if($.trim(value) == '')
{
return 'Ce Champ Est Obligatoire';
}
}
});
$('#employee_data').editable({
container: 'body',
selector: 'td.Presneceb',
url: "http://localhost/wordpress/update",
title: 'Presneceb',
type: "POST",
dataType: 'json',
source: [{value: "Non", text: "Non"}, {value: "Oui", text: "Oui"}],
validate: function(value){
if($.trim(value) == '')
{
return 'Ce Champ Est Obligatoire';
}
}
});
$('#employee_data').editable({
container: 'body',
selector: 'td.Presnecec',
url: "http://localhost/wordpress/update",
title: 'Presnecec',
type: "POST",
dataType: 'json',
source: [{value: "Non", text: "Non"}, {value: "Oui", text: "Oui"}],
validate: function(value){
if($.trim(value) == '')
{
return 'Ce Champ Est Obligatoire';
}
}
});
});
</script>
+0
這裏一樣的東西。更新您的問題以添加相關代碼,如果不是答案,請不要添加答案。請花一些時間閱讀[如何創建最小,完整和可驗證示例](https://stackoverflow.com/help/mcve)。 –
相關問題
- 1. 在AJAX呼叫之後,下一個AJAX呼叫不起作用
- 2. 呼叫AJAX功能
- 3. 呼叫從一個UIWebView使用Ajax
- 4. Ajax呼叫等待另一個Ajax呼叫的響應?
- 5. 我如何能夠使用AJAX呼叫
- 6. 呼叫使用Ajax或PHP
- 7. 通過AJAX呼叫PHP
- 8. PHP ajax呼叫失敗
- 9. PHP - 呼叫從一個字符串中
- 10. 呼叫從另一個php文件
- 11. 呼叫的兩個AJAX功能單擊
- 12. 呼叫FO從PHP
- 13. 呼叫功能從
- 14. 呼叫JPA /從使用Ajax
- 15. PHP,AJAX和HTML,功能從不叫
- 16. 呼叫從一個makefile內
- 17. 呼叫從一個MapViewController
- 18. 呼叫從一個javascript
- 19. 呼叫從一個Java Bean
- 20. 呼叫和AJAX
- 21. 呼叫直接從PHP陣列功能
- 22. 呼叫與PHP
- 23. 呼叫從一個元素AJAX父頁面的功能 - 裝載到一個div
- 24. 以角度呼叫另一個http呼叫中的http呼叫
- 25. 呼叫的「grep」,並從PHP
- 26. 呼叫的PowerCLI從PHP
- 27. 呼叫在PHP
- 28. 呼叫使用AJAX
- 29. AJAX重複呼叫
- 30. Ajax呼叫延遲
人們試圖編輯ÿ我們的問題讓它變得更好 - 請不要再讓它變得更糟。 – Tom
代碼在哪裏? – ggdx
看起來像你迴應全頁面內容而不是單行文本。 – Justinas