1

我想以表格形式显示数据库中的数据。我写了以下代码

while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['EmpID'] . "</td>";
echo "<td>" . $row['EmpName'] . "</td>";
echo "<td>" . $row['Designation'] . "</td>";
echo "<td>" . $row['Salary'] . "</td>";
echo "<td><a href='upasg3.php?empid='". $row['EmpID'] .">Edit</a ></td>";
echo "<td><a href='upasg3.php?empid='". $row['EmpID'] .">Delete</a ></td>"; 
echo "</tr>";
}

但我没有得到 $row['EmpID'] 的值与 href 的值连接。它重定向到 empid= 空白的 upasg3.php。如何解决这个问题?请帮忙

4

5 回答 5

4
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['EmpID'] . "</td>";
echo "<td>" . $row['EmpName'] . "</td>";
echo "<td>" . $row['Designation'] . "</td>";
echo "<td>" . $row['Salary'] . "</td>";
echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Edit</a ></td>";
echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Delete</a ></td>"; 
echo "</tr>";
}

引号。

于 2012-05-17T09:54:16.807 回答
2

尝试删除 empid= 后的单引号

并把它们放在这里:

echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Edit</a ></td>";
echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Delete</a ></td>"; 

这将为您提供如下输出:

<a href='upasg3.php?empid=100'>
于 2012-05-17T09:53:50.937 回答
1

尝试

echo "<td><a href='upasg3.php?empid=". $row['EmpID']."'>Edit</a ></td>";
                                    ^                 ^
于 2012-05-17T09:56:27.990 回答
1
 <table width="100%" border="1">
  <tr>
 <td>ID</td>
<td>NAME</td>
<td>Designation</td>
<td>Salary</td>
<td>Edit</td>
  <td>Delete</td>
</tr>
<tr>
  <td><?=$row['EmpID']?></td>
<td><?=$row['EmpName']?></td>
<td><?=$row['Designation']?></td>
<td><?=$row['Salary']?></td>
<td><a href="upasg3.php?empid=<?=$row['EmpID']?>">Edit</a></td>
 <td><a href="upasg3.php?empid=<?=$row['EmpID']?>">Delete</a></td>
 </tr>

于 2012-05-17T10:01:08.440 回答
-1

尝试这个

echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Edit</a ></td>";
echo "<td><a href='upasg3.php?empid=". $row['EmpID'] ."'>Delete</a ></td>"; 

你的报价放错地方了。

于 2012-05-17T09:59:55.633 回答