用户从选择框中选择一个值,然后通过表单传递给另一个页面,该页面应显示该选择的mysql记录。这没有显示任何结果,但是值肯定会被传递,因为它可以被回显。
<?php
include("top.php");
$db = getConnection();
$eventID = $_POST['eventID'];
echo $eventID;
$queryEvent = $db->query("SELECT * FROM projectEvent WHERE eventID = '$eventID'");
$queryEvent->setFetchMode(PDO::FETCH_ASSOC);
$record = $queryEvent->fetchALL();
?>
<form name="form1" id="form1" method="post" action="deleteOpen.php">
<p> are you sure you want to delete the following Open Day? </p>
<table width="200" cellpadding="0" cellspacing="0">
<tr>
<th scope="row">eventID</th>
<td><?php echo $record -> eventID; ?></td>
</tr>
<tr>
<th scope="row">propertyID</th>
<td><?php echo $record -> propertyID; ?></td>
</tr>
<tr>
<th scope="row">eventDate</th>
<td><?php echo $record -> eventDate; ?></td>
</tr>
<tr>
<th scope="row">eventTime</th>
<td><?php echo $record -> eventTime; ?></td>
</tr>
<tr>
<th scope="row">eventDescription</th>
<td><?php echo $record -> eventDescription; ?></td>
</tr>
</table>
有人可以建议为什么这些值没有显示在表格中吗?
由于
答案 0 :(得分:5)
error_reporting(E_ALL);
看到这些愚蠢的错误。答案 1 :(得分:0)
您可以像这样单独连接变量:
$queryEvent = $db->query("SELECT * FROM projectEvent WHERE eventID = ".$eventID.")";
答案 2 :(得分:-1)
通常我会对方法略有不同。它可能没有指出问题,但我认为它将解决它。我通常不会在引号内使用变量,但请尝试以下。
$sql = sprintf("SELECT * FROM projectEvent WHERE eventID = '%s'", $eventID);
$queryEvent = $db->query($sql);