Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 制作讨论板,如何让更多人回答_Php_Mysql - Fatal编程技术网

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

Php 制作讨论板,如何让更多人回答,php,mysql,Php,Mysql,我正在用php和mysql做一个讨论板,但我的问题是;我怎样才能让一个以上的人能够对一个讨论做出反应,就像我现在看到的只有一个人能够做出反应,因为它进入了数据库中名为的字段;反应 但我当然希望有更多的人来回答,而不是一个人 如果有人能告诉我如何做到这一点,那将是市长的帮助 到目前为止我尝试的代码: <?php include('inc/conn.inc.php'); ?> <?php if(isset($_POST['post'])){ $reactions= $_POST

我正在用php和mysql做一个讨论板,但我的问题是;我怎样才能让一个以上的人能够对一个讨论做出反应,就像我现在看到的只有一个人能够做出反应,因为它进入了数据库中名为的字段;反应

但我当然希望有更多的人来回答,而不是一个人

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

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

<?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>

讨论板
这里有标志
作为特色的
地位
特色项目在这里{讨论}由php部署
董事会状态在这里{status}由php部署
信息:

页脚内容


每次有人按下POST按钮,它都会取代字段吗

首先需要以这种方式分隔表:

一旦这样做,您就可以开始使用连接创建查询以获取数据。这样做,然后告诉我们,如果你有进一步的困难


希望这能有所帮助。

到目前为止,您尝试了哪些代码?您必须阅读更多关于数据库规范化的内容。答案/反应应该放在他们自己的表中。我还必须学习如何在PHP中使它们链接在一起,当有人作出反应时,反应会转到正确的post+$sql=$conn->prepare(“插入主题(反应)值(:反应),其中id=:id”)$sql->bindParam(':id',$id)$sql->bindParam(':reactions',$reactions)$sql->execute();这是永远不会起作用的,插入不支持在哪里?