制作讨论板,如何让更多人回答

时间:2016-03-20 12:07:15

标签: php mysql

我在php和mysql的讨论板上工作,但我的问题是;我怎么能让超过1个人能够对讨论做出反应,就像我现在只有一个人可以做出反应一样,因为它进入了数据库中的一个字段;反应

但我想让更多的人回答它而不是一个......

如果有人能告诉我如何实现这一点,那将是市长的帮助!

我到目前为止尝试的代码:

<?php
include('inc/conn.inc.php');
?>
<?php
if(isset($_POST['post'])){
  $reactions= $_POST['msg'];
$sql = "INSERT INTO topics (reactions) VALUES reactions = :reactions";
$sql->bindParam(':reactions', $reactions);
$results = $conn->exec($sql);

}
?>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="css/styles.css">
  <link rel="stylesheet" type="text/css" href="css/reset.css">
  <title>Discussion Board</title>
</head>
<body>
  <header>
    <h1>Logo comes in here</h1>
  </header>
  <div id="t1">
    <h1>Featured</h1>
  </div>
  <div id="t2">
    <h1>Status</h1>
  </div>
  <div id="topic-items">
    <?php

    $id = htmlspecialchars($_GET["id"]);
/*
    $sql = "SELECT creator FROM topics WHERE id = :id";
    $sql->bindParam(':id', $id);
    $results = $conn->query($sql);
*/

    $statement = $conn->prepare("SELECT message FROM topics where id = :id");
    $statement->execute(array(':id' => $id));
    $row = $statement->fetch();
    echo "Message: ".$row['message'];

    ?>
    <h2>Featured items come here {discussions} deployed by php </h2>
  </div>
  <div id="board-status">
    <h2>Board statuses come here {status} deployed by php </h2>
  </div>
  <div id="react-board">
    <form>
      Message:<br>
      <textarea name="msg"></textarea><br>
      <input type="submit" name="post" value="Post">
    </form>
  </div>
  <footer>
    <h1>Footer Content</h1>
  </footer>
</body>
</html>

enter image description here

每次有人按下POST按钮时,是否会更换现场?

1 个答案:

答案 0 :(得分:0)

您需要先以这种方式分离您的表格:

enter image description here

一旦这样做,您就可以开始使用JOIN创建查询以获取数据。这样做,然后告诉我们你是否还有其他困难。

希望这有帮助。

相关问题