我有一個非常舊的腳本,我需要修改。 您将從代碼中注意到它使用的是mysql_query(),但這不是我的問題。
我在名為surveycommentslist.php的檔案中有一個文本連結。 該連結打開一個jquery模型視窗,我需要捕獲使用者輸入的文本,然後将其儲存到mysql以及連結data-id的值,該值告訴我連接配接注釋的唯一使用者ID。 我的問題是我無法使用下面的代碼擷取data-id的值。
這是我的代碼
$(document).on('click', '.reply', function()
{
//get acommentuid
var val = $(this).attr('data-id');
$.post('surveycommentslist.php', {acommentuid: val}, function(data)
{
console.log(data);
});
});
//lets list comments
$scommentsql = mysql_query("SELECT * FROM survey_comments
WHERE surveyid=$surveyid ORDER BY commentdate asc");
while($scrows = mysql_fetch_array($scommentsql))
{
extract($scrows);
$the_comment = stripslashes($the_comment);
$commentdate = date("m/d/Y h:ia", strtotime($commentdate));
if($touid > 0) { $indent = "margin-left:35px"; }
//get name of person making the comment
$nsql = mysql_query("SELECT fname, lname, userlevel, id AS scommentid FROM users WHERE id=$uid LIMIT 1");
$namerow = mysql_fetch_array($nsql);
$commenters_fname = stripslashes($namerow['fname']);
$commenters_lname = stripslashes($namerow['lname']);
if($namerow['userlevel'] > 19)
{
$adminicon = "

";
}
echo "
$the_comment
$adminicon $commenters_fname $commenters_lname
$commentdate";
if($touid == 0)
{
echo " REPLY";
}
echo "
";
}