这有什么不对?尝试了很多

时间:2014-12-22 17:56:18

标签: php html mysql phpmyadmin

我写了一段PHP代码。我无法从数据库中检索结果。在提交它juz给出一个空白页面widout抛出任何错误。我是新手,所以即使你认为这是一个愚蠢的问题,请回复。请参阅代码,并向我建议一些将使我的代码正常工作的更改。



<!DOCTYPE html>
<html>

<head>
	<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>

	<title>EDIT SCREEN</title>


	<form action="test4.php" method="post">
		<ul>
			
			<li>
				Employee ID:</br>
				<input type="text" name="eid">
			</li>

			<li>
				<input type="submit" value="SUBMIT">
			</li>
		</ul>

	</form>

</body>

</html>

//test4.php file

$value1 = $_POST['eid'];

$res = $mysql_query(SELECT * from `add` WHERE empid = `$value1`);


echo "<table border='1'>
      <tr><th>Name</th>
      <th>EmployeeID</th><th>Address</th></tr>";

         while($row = mysql_fetch_array($res))
         {
            echo "<tr>";
            echo "<td>" . $row['name'] . "</td>";
            echo "<td>" . $row['empid'] . "</td>";
            echo "<td>" . $row['add'] . "</td>";
            echo "</tr>";
         }
         echo "</table>";
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:5)

您有两个<form>代码:

<form>   <---this is the one being used by the browser to submit
    <form action="test3.php" method="post">  <--this will be ignored outright

没有属性的普通<form>标记将被视为:

<form action="" method="get">

将简单地提交&#34;到表单页面加载的任何地址。