This question already has answers here:
The 3 different equals
(5个答案)
3年前关闭。
我有一个网址链接,该网址链接在单击时具有ID和进程的值。
码:
这是页面将重定向到的位置:
问题是2 if条件触发,为什么同时触发?
(5个答案)
3年前关闭。
我有一个网址链接,该网址链接在单击时具有ID和进程的值。
码:
<?php
<a href='settoActive.php?id=".$row['id']."&process=actives' style='font-size:15px;' name='active' value=".$row['id']." class='btn btn-info' />ACTIVE</a>
?>
<a href='settoActive.php?id=".$row['id']."&process=inactive' style='font-size:15px;' name='active' value=".$row['id']." class='btn btn-info' />inactive</a>
这是页面将重定向到的位置:
<?php
$value = $_GET['process'];
echo "<script> alert(".$value.");</script> ";
if($_GET['proc']="actives"){
$id = $_GET['id'];
$mysqli = new mysqli('10.237.2.152','root','c0k3float','monitoring');
$results = $mysqli->query("UPDATE Shipment_Target SET status='Active' where id=".$id." ") or mysqli0;
echo "<script>alert('Activessss!'); </script>";
//location.replace('addmodel.php')
}
if($_GET['process']="inactive"){
$id = $_GET['id'];
$mysqli = new mysqli('10.237.2.152','root','c0k3float','monitoring');
$results = $mysqli->query("UPDATE Shipment_Target SET status='Inactive' where id=".$id." ") or mysqli0;
echo "<script>alert('Inactive!'); </script>";
}
// location.replace('addmodel.php')
?>
问题是2 if条件触发,为什么同时触发?
最佳答案
注意到3个错误... 2个'=='运算符和1个GET变量名'process'。
$value = $_GET['process'];
echo "<script> alert(".$value.");</script> ";
if($_GET['process']=="actives"){
$id = $_GET['id'];
$mysqli = new mysqli('10.237.2.152','root','c0k3float','monitoring');
$results = $mysqli->query("UPDATE Shipment_Target SET status='Active' where id=".$id." ") or mysqli0;
echo "<script>alert('Activessss!'); </script>";
//location.replace('addmodel.php')
}
if($_GET['process']=="inactive"){
$id = $_GET['id'];
$mysqli = new mysqli('10.237.2.152','root','c0k3float','monitoring');
$results = $mysqli->query("UPDATE Shipment_Target SET status='Inactive' where id=".$id." ") or mysqli0;
echo "<script>alert('Inactive!'); </script>";
}
// location.replace('addmodel.php')
?>
关于javascript - $ _GET无法在我的php文件上使用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41033243/
10-12 16:44