我需要帮助。
在我的 index.php 中成功搜索结果后,如何将变量(在 url 内)调用到下一页 view.php,以便我可以查看变量的完整数据?
这是我的代码
“索引.php”
<form method="post" action="index.php?go" id="searchform">
<input type="text" name="name" size = "50">
<br/>
<input type="submit" name="submit" value="SEARCH">
<button type="reset" value="Reset">RESET</button>
</form>
<?php
$db=mysql_connect ("localhost", "root", "") or die ('I cannot connect to the database because: ' . mysql_error());
$mydb=mysql_select_db("emp_dbA");
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/[A-Z | a-z]+/", $_POST['name'])){
$name=$_POST['name'];
$letter=$_GET['by'];
$sql="SELECT emp_ID, fname, lname,mname FROM emp_tbl WHERE fname LIKE '%" . $name . "%' OR lname LIKE '%" . $name ."%' OR mname LIKE '%" .$name . "%'";
$result=mysql_query($sql);
$numrows=mysql_num_rows($result);
echo "<p>" .$numrows . " results found for " . stripslashes($name) . "</p>";
while($row=mysql_fetch_array($result)){
$fname =$row['fname'];
$mname =$row['mname'];
$lname=$row['lname'];
$ID=$row['emp_ID'];
echo "<ul>\n";
echo "<li>" . "<a href=\"view.php?id=$fname\">" .$fname . " " . $mname. " " . $lname . "</a></li>\n";
echo "</ul>";
}
}
else{
echo "<p>Please enter a search query</p>";
}
}
}
?>