当我在字段(部分,文档标题等)上输入值然后单击提交时,它会显示一个弹出的对话框,它已被发送到数据库(我的php文件中没有错误database-displayQM.php)。当我点击“确定”时,它会重定向到我的主要php文件的表单操作上的另一个页面。它如何保持在同一页面而不是重定向?
这是我的代码:
<?php
?>
<html>
<head>
<link rel="shortcut icon" href="favicon.ico" >
<link rel="stylesheet" type="text/css" href="text.css" />
<title>Quality Management System</title>
<script language = "javascript">
function myFunction() {
confirm("Sent to Database!");
}
</script>
</head>
<body>
<center>
<img src = "logo.png">
<body bgcolor = "#191970">
<p>
<font color= #FFF8DC>
<font face = "Verdana">
<font size = 6>
<b> QMS - Quality Management System</b>
</font>
<p>
<ul id="menu-bar">
<li><a href="index.php">Home</a></li>
<li><a href="QualityManual.php">Quality Manual</a></li>
<li><a href="QualityProcedures.php">Quality Procedures</a></li>
<li><a href="WorkInstructions.php">Work Instructions</a></li>
<li><a href="#">Support Documents</a>
<ul>
<li><a href="QualityForms.php">Quality Forms</a></li>
<li><a href="Reference.php">Reference</a></li>
<li><a href="JobDescription.php">Job Description</a></li>
</ul>
</ul>
<p>
<font size = 6 font face = "Verdana" font color= #FFF8DC> Quality Manual</font>
<p>
<br>
<form action = "displayQM.php" method = "post" onsubmit="myFunction()">
<table BORDER="2" style="border:5px solid white;border-collapse:collapse;">
<tr>
<th rowspan="2" bgcolor = "#D3D3D3"><font face = "Verdana">Section</th>
<th rowspan="2" bgcolor = "#D3D3D3"><font face = "Verdana">Title of Documents</th>
<th rowspan="2" bgcolor = "#D3D3D3"><font face = "Verdana">Document No.</th>
<th colspan="5" bgcolor = "#D3D3D3"><font face = "Verdana">Revision Status </th>
<th rowspan="2" bgcolor = "#D3D3D3"><font face = "Verdana">Number <br>of Pages</th>
</tr>
<tr>
<td bgcolor = "#D3D3D3"><font face = "Verdana"><center>0</center></td>
<td bgcolor = "#D3D3D3"><font face = "Verdana"><center>1</td>
<td bgcolor = "#D3D3D3"><font face = "Verdana"><center>2</td>
<td bgcolor = "#D3D3D3"><font face = "Verdana"><center>3</td>
<td bgcolor = "#D3D3D3"><font face = "Verdana"><center>4</td>
</tr>
<tr>
<td><input type = "text" name = "QMsection_1" size = "9" placeholder="(Enter Section)" value = "" maxlength = "5" align = "right" tabindex ="1"></td>
<td><input type = "text" name = "QMtitleofdocuments_1" size = "30" placeholder="(Enter Title of Document)" value = "" maxlength = "100" align = "right" tabindex ="1"></td>
<td><input type = "text" name = "QMdocumentno_1" size = "14" placeholder="(Enter Document No.)" value = "" maxlength = "100" align = "right" tabindex ="1"></td>
<td><input type = "text" name = "QMrevisionstatus0_1" size = "7" value = "" maxlength = "10" align = "right" tabindex ="1"></td>
<td><input type = "text" name = "QMrevisionstatus1_1" size = "7" value = "" maxlength = "10" align = "right" tabindex ="1"></td>
<td><input type = "text" name = "QMrevisionstatus2_1" size = "7" value = "" maxlength = "10" align = "right" tabindex ="1"></td>
<td><input type = "text" name = "QMrevisionstatus3_1" size = "7" value = "" maxlength = "10" align = "right" tabindex ="1"></td>
<td><input type = "text" name = "QMrevisionstatus4_1" size = "7" value = "" maxlength = "10" align = "right" tabindex ="1"></td>
<td><input type = "text" name = "QMnumofpages_1" size = "10" value = "" maxlength = "3" align = "right" tabindex ="1" ></td>
</tr>
</table>
<p>
<input type="submit" value="Submit" name="submit">
</p>
</form>
</body>
</html>
答案 0 :(得分:0)
将操作值保持为空
$qry="SELECT distinct course as c, (SELECT lecturer from courses where course=c limit 1) as l FROM courses";
$results=mysql_query($qry);
if($results)
{
if(mysql_num_rows($results) > 0)
{
while ($rows = mysql_fetch_array($results))
{
echo "<center><table width=400 border=1>";
echo "<tr><td><b> Course Name : </b></td><td>". $rows["c"]."</td></tr>
<tr><td><b> Lecturer Name : </b></td><td>". $rows["l"]."</td></tr>
<tr><td><b> Time : </b></td>"
$qry2="SELECT time FROM courses WHERE courses.course='".$rows['c']."' and courses.lecturer='".$rows['l']."'";
$results2=mysql_query($qry2);
if($results2)
{
while($rows2 = mysql_fetch_array($results2))
{
echo"<td>".$rows2['time']."</td>";
}
}
echo"</tr>";
}
echo "</center></table><br>"
}
else {echo "<center>not available</center>";}
}