【发布时间】:2012-03-11 22:15:07
【问题描述】:
我想知道是否有人可以帮助我。
我将下面的代码放在一起尝试并允许用户通过单选按钮选择检索 mySQL 记录,然后在我的 html 表单上填充一个表。
表格
<html>
<head>
<script type="text/javascript">
function ajaxFunction(name)
{
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer")
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{// code for IE6, IE5
xmlhttp=new XMLHttpRequest();
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("my_div").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getrecords.php?dateoftrip="+name,true);
xmlhttp.send();
}
function getquerystring() {
var form = document.forms['frm1'];
var word = form.word.value;
qstr = 'w=' + escape(word); // NOTE: no '?' before querystring
return qstr;
}
</script>
<style type="text/css">
<!--
.style1 {
font-family: Calibri;
font-size: 14px;
}
-->
</style>
</head>
<body>
<form action="getrecords.php" method="get" name="frm1">
<table width="148" border="0">
<tr>
<td width="152"><p class="style1">Select a date from below</p>
<div align="center">
<?php
include("db.php");
$query="select userid, dateoftrip from finds group by dateoftrip";
$result=mysql_query($query);
while (list($userid, $dateoftrip) =
mysql_fetch_row($result))
{
echo"<tr>\n"
.
'<td><input type='radio' name='name' dateoftrip value='{$userid}' onchange="ajaxFunction(this.value)"/></td>\n'
.'<td><small>{$dateoftrip}</small><td>\n'
.'</tr>\n'
}
echo"<tr><td colspan=\"3\">";
echo"<br>";
echo"</td></tr>";
echo'</table>';
?>
</div></td>
</tr>
</table>
</form>
<div id="my_div"></div>
</body>
</html>
getrecords.php
<?php
include("db.php");
$dateoftrip= $_GET['dateoftrip'];
$findname= $_GET['findname'];
$finddescription= $_GET['finddescription'];
$query="select * from finds where dateoftrip='$dateoftrip'";
echo "<table>";
$result=mysql_query($query);
while($rows=mysql_fetch_array($result)){
echo "<tr>";
echo "<td>Find Name : </td>";
echo "<td>".$rows['findname']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Find Description : </td>";
echo "<td>".$rows['finddescription']."</td>";
echo "</tr>";
}
echo "</table>";
?>
我遇到的问题是我收到以下错误,但我不确定为什么:Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /homepages/2/d333603417/htdocs/development/ajaxfunction.php on line 69 第 69 行是我的 html 表单代码的这一行:
'<td><input type='radio' name='name' dateoftrip value='{$userid}' onchange="ajaxFunction(this.value)"/></td>\n'
我已经为此工作了一段时间,但到目前为止我还没有成功解决它。我只是想知道是否有人可以看看这个,让我知道我哪里出错了。
非常感谢
【问题讨论】: