繁体   English   中英

PHP Mysql单选按钮选择

[英]PHP Mysql radio buttons selection

有人可以帮助我,我正在尝试实现一个简单的PHP MySQL调查,但我坚持这一点,我如何存储用户选择的MySQL中的特定选择。

你有多满意:

<table id="table1" rules="all" border="1" cellpadding="3" cellspacing="0" width="70%">
    <colgroup width="70%"></colgroup>
    <colgroup width="6%">
    </colgroup>
    <thead>
        <tr align="center">
           <th></th>
           <th font="" style="font-size:9pt;" size="2"><b>Dissatisfied</b></th>
           <th font="" style="font-size:9pt;" size="2"><b>Satisfied</b></th>
           <th font="" style="font-size:9pt;" size="2"><b>Very Satisfied</b></th> 
        </tr>
   </thead>
   <tbody>
       <tr align="center">
           <td align="left"><font style="font-size:10pt;"><b>Technician's ability to understand the unique nature of your problem?</b></font></td>
           <td><input name="satisfaction" value="Dissatisfied"  type="radio"></td>
           <td><input name="satisfaction" value="Satisfied"  type="radio"></td>
           <td><input name="satisfaction" value="Very Satisfied"  type="radio"></td>

       </tr>
       <tr align="center">
   </tbody>
</table>

为此您需要一个表单来提交数据选择。 你需要两个php文件

第一个是构建一种单选按钮 我删除了表的元素以获得整洁的视图然后我们设置了第二页的URL。如果你想要,也可以是单个页面,但这更容易。

feedback.php

 <form action="add.php" method="post" accept-charset="utf-8">
     <input name="satisfaction" value="Dissatisfied"  type="radio">Dissatisfied<br>
     <input name="satisfaction" value="Satisfied"  type="radio">Satisfied<br>
     <input name="satisfaction" value="Very Satisfied"  type="radio">Very Satisfied<br>

     <input type='submit' value="submit">
</form>

在第二页, 我们抓住了从第一页发布的内容

add.php

  $result= $_POST['satisfaction'];
  echo $result;

使用$ result存储在您的数据库中。 祝好运

很简单:

1,在表标记之前添加此行:

<form method="post" action="">

2,代码末尾的这个:

<input type="submit" name="submit" value="Submit">
</form>

然后,您可以将此代码插入数据库中。

if ($stmt = $mysqli->prepare("INSERT INTO TABLENAME(COLUMN NAME) values (?)")) {
     $stmt->bind_param('s', $satisfaction);


    $satisfaction=$_POST['satisfaction'];

     $stmt->execute();

    $stmt->close();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM