dpvmtdu364462 2014-09-14 15:50
浏览 14
已采纳

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

My Html File

<!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>

My Php file :

<?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>";
}
?>

When i submit the form it showing like this error

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

Actually i am trying to retrieve the name,halltickets if i submit value dynamically by checking with hallticket, Please tell me what is the problem

  • 写回答

1条回答 默认 最新

  • dswqz24846 2014-09-14 16:21
    关注
    $hallticket = $_GET["hallticket"]; 
    mysqli_real_escape_string($con,$hallticket); 
    $result = mysqli_query($con,"SELECT * FROM details WHERE hallticket='$hallticket'"); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分