gpt4 book ai didi

javascript - 通过动态接受输入来检索数据

转载 作者:行者123 更新时间:2023-12-03 11:51:05 26 4
gpt4 key购买 nike

我的 Html 文件

<!DOCTYPE html>
<html>
<head>
<script>
function myfun(){
var x,y,z;
x=document.input.name.value;
if((x=="")||(x==null))
{
alert("Please Enter Your Name");
document.input.name.focus();
return false;
}
y=document.input.hallticket.value;
if((y=="")||(y==null))
{
alert("Please Enter Your Hallticket");
document.input.hallticket.focus();
return false;
}
z=document.input.dob.value;
if((z=="")||(z==null))
{
alert("Please Enter Your Dob");
document.input.dob.focus();
return false;
}


}
</script>
<style>
h1{
text-align:center;
}
#header{
background-color:#985544;
}
#left{
background-color:#789564;
}
#center{
background-color:#888999;
}
#body{
background-image:url(bodyback.png);
}
#right{
background-color:#789564;
}
</style>
</head>
<body id="body" style=" no-repeat">
<div id="header" style="height:100px;width:100%">
</div>
<marquee>Welcome to CSE-A Website</marquee>
<div>
<div id="left" style="height:1000px;width:10%;float:left">
</div>
<div id="center" style="height:px;width:80%;float:left">
<h1>CSE-A</h1>
<p>Here you can check your details in this site :)</p>

<form name="input" action="data.php" id="searchform">
Name: <input type="text" name="name">
HallticketNo: <input type="text" name="hallticket">
Dob:<input type="date" name="dob">
<Input onclick="return myfun();" type="Submit" name="Submit" value="Search" id="n3"/>
</form>

</div>
<div id="right" style="height:1000px;width:10%;float:left">
</div>
</div>
</body>
</html>

我的 PHP 文件:

<?php
$con=mysqli_connect("localhost","prabha","prabha","cvsr");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM details WHERE hallticket='$_GET["hallticket"]'");

while($row = mysqli_fetch_array($result)) {
echo $row['name'] . " " . $row['hallticket'];
echo "<br>";
}
?>

当我提交表单时,它显示这样的错误

Parse error: parse error, expecting T_STRING' orT_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\New folder\data.php on line 8

实际上,我正在尝试检索名称,halltickets,如果我通过检查 Hallticket 动态提交值,请告诉我问题是什么

最佳答案

$hallticket = $_GET["hallticket"]; 
mysqli_real_escape_string($con,$hallticket);
$result = mysqli_query($con,"SELECT * FROM details WHERE hallticket='$hallticket'");

关于javascript - 通过动态接受输入来检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25835085/

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