PHP没有显示任何值,但值肯定被传递

Dar*_*ess 1 php mysql forms

用户从选择框中选择一个值,然后通过表单传递给另一个页面,该页面应该显示该选择的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>
Run Code Online (Sandbox Code Playgroud)

任何人都可以建议为什么表中没有显示这些值?

谢谢

You*_*nse 5

  1. 要显示数据,你不应该使用POST方法,而是使用GET.
  2. 使用PDO :: quote转义值或使用prepare/execute而不是query()使用预准备语句
  3. 如果您使用ASSOC模式 - 为什么要将它们作为对象属性访问?
  4. 此外,您实际上有一个嵌套数组,但作为单个对象访问它.如果你不需要数组 - 那么就不要使用fetchAll()
  5. 总是error_reporting(E_ALL);在你的脚本中看到这些愚蠢的错误.