我正在尝试根据其 ID 从数据库中列出一条记录。我有一个脚本列出了数据库中的所有记录并在 html 表中显示记录。在表中,有一行“活动”是单击时仅显示一行记录的链接。想法是仅列出具有电子邮件的行,否则显示一条消息,说明没有可用的电子邮件
这是脚本
//database connection details
$id =$_REQUEST['id'];
$email =$_REQUEST['email'];
if($email != "")
{
$query = mysql_query("SELECT * FROM $tbl_name WHERE id='$id'");
echo "<table border = 1 cellpadding = 5> <tr> <th> Name </th> <th> Address </th> <th> City </th> <th> State </th> <th> Postal Code </th> <th> Voice </th> <th> Email </th> <th> Status </th> </tr>";
while($row = mysql_fetch_array($query))
{
echo "<tr>";
echo "<td> $row[1] </td>";
echo "<td> $row[2] </td>";
echo "<td> $row[3] </td>";
echo "<td> $row[4] </td>";
echo "<td> $row[5] </td>";
echo "<td> $row[6] </td>";
echo "<td> $row[7] </td>";
echo "<td> $row[8] </td>";
echo "</tr>";
}
echo "</table>";
}
else
echo 'That record does not have an Email';
但我在运行脚本时收到错误“未定义的索引:电子邮件”..请帮助