-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. 呼叫使用Ajax或PHP
- 4. PHP - 呼叫从一个字符串中
- 5. 呼叫FO从PHP
- 6. 呼叫功能从
- 7. 呼叫JPA /从使用Ajax
- 8. PHP,AJAX和HTML,功能从不叫
- 9. 呼叫从一个Java Bean
- 10. 呼叫从一个javascript
- 11. 呼叫从一个makefile内
- 12. 呼叫从一个元素AJAX父页面的功能 - 装载到一个div
- 13. 呼叫的PowerCLI从PHP
- 14. 呼叫在PHP
- 15. 取消ajax呼叫?
- 16. 刷新AJAX呼叫
- 17. Ajax呼叫延迟
- 18. 呼叫从JQ功能
- 19. 声明一个模块,导出一个自我呼叫功能
- 20. jQuery AJAX呼叫 - 是否可以取消不需要的呼叫?
- 21. Ajax呼叫传递参数到功能
- 22. 呼叫功能
- 23. 呼叫功能
- 24. 呼叫功能
- 25. 呼叫功能
- 26. 呼叫功能
- 27. 呼叫功能
- 28. 呼叫功能
- 29. 呼叫从我Timer.Tick事件
- 30. 呼叫时,功能不respondong
人们试图编辑ÿ我们的问题让它变得更好 - 请不要再让它变得更糟。 – Tom
代码在哪里? – ggdx
看起来像你回应全页面内容而不是单行文本。 – Justinas