gpt4 book ai didi

JavaScript/PHP : Get input from prompt and update the database

转载 作者:行者123 更新时间:2023-12-02 17:42:46 24 4
gpt4 key购买 nike

所选事件的标题需要更改为提示符下输入的内容。

但它没有按预期工作。请提出建议/建议

JavaScript 函数:

eventMouseover: function(event, domEvent) {
var layer = '<div id="events-layer" class="fc-transparent" style="position:absolute; width:100%; height:100%; top:-1px; text-align:right; z-index:100"><a><img src="../../images/editbt.png" title="edit" width="14" id="edbut'+event.id+'" border="0" style="padding-right:3px; padding-top:2px;" /></a></div>';

$("#edbut"+event.id).hide();
$("#edbut"+event.id).fadeIn(300);
$("#edbut"+event.id).click(function() {
var title = prompt( '\n\nNew Event Title: ');
if(title){
$.ajax({
url: '<?=base_url();?>testcalendar/fullcalendar/update_title.php',
data: 'title='+ event.title+'&id='+ event.id ,
type: "POST",
});
}
});
},

PHP 表单 (update_title.php):

<?php
$id = $_POST['id'];
$title = $_POST['title'];
// connection to the database
try {
$bdd = new PDO('mysql:host=localhost;dbname=blackboks-calendar', 'root', 'root');
} catch(Exception $e) {
exit('Unable to connect to database.');
}
// update the records
$sql = "UPDATE evenement SET title=". $title ."WHERE id=".$id;
$q = $bdd->prepare($sql);
$q->execute();
?>

最佳答案

问题出在您发送标题时。它应该是标题而不是 event.title

改变

   data: 'title='+ event.title+'&id='+ event.id ,

    data: 'title='+ title+'&id='+ event.id ,

关于JavaScript/PHP : Get input from prompt and update the database,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22042643/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com