【发布时间】:2021-06-03 09:02:24
【问题描述】:
我是这个领域的新手,甚至不是初中生1[新] 到 0[旧] 这些是我的脚本...这项工作但此查询将我所有状态为 1 的消息更改为 0,我只需要更改发件人的姓名。
这些是我的文件:这里是带有脚本 ID 的输入
echo "
<img style='display:inline-block;height:100px;width:100px;' src='images/newmessage.png'>
<a href='conversatie.php?catre=" . $row['nume'] . "'>
<input style='display:inline-block;font-size:15px;height:40px; ' class='button' id='messagechangestatus' onclick='messagechangestatus()' type='submit' value='".$row['nume']."'></a> ;
这是同一页面中的脚本:
<script type="text/javascript">
var x = document.getElementById("messagechangestatus").value;
function messagechangestatus () {
$.ajax({
url:"includes/changestatus.php",
type: "POST",
data: x,
success:function(result){
alert(result);
}
});
}
</script>
这是我的 changestatus.php 页面:
<?php
session_start();
require "conectare.php";
$author = $_SESSION['prenume'];
$sql = "SELECT * FROM messages WHERE catre='$author' AND status='1'" ;
$result = mysqli_query($conectare, $sql);
if(mysqli_num_rows($result) > 1){
$author = $_SESSION['prenume'];
$sql2 = "UPDATE messages
SET status='0' WHERE catre='$author'";
mysqli_query($conectare, $sql2);
header("Location: mesaje.php");
exit();
}
echo "Nu functioneaza";
?>
我想让我的 sql 查询类似于:
$sql2 = "UPDATE messages
SET status='0' WHERE catre='$author' AND name =' ****And here to be the value of my input**** '";
接下来我可以做什么来在我的 sql 中获取这个输入值?
【问题讨论】: