2013-04-20 64 views
1

有人可以帮助我,我想实现一个简单的PHP MySQL调查,但我坚持这一点,我如何存储用户选择的MySQL中的具体选择。PHP的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> 
+1

[你到目前为止尝试过什么](http://whathaveyoutried.com/)?很久以前我上次见到''标签... – CodeZombie 2013-04-20 22:43:52

回答

2

为此,你需要什么需要形式提交数据的选择。您将需要两个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; 

使用$结果在数据库中存储。祝你好运

1

简单:

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(); 
} 
+0

谢谢亿亿Wayne Tun Myint,auicsc快速回复,Wayne – user2303233 2013-04-21 04:53:36

+2

谢谢亿万Wayne Tun Myint,快速回复auicsc,Wayne很快和容易,我真的很感谢你的帮助,我希望有一天我会像你一样帮助别人,Ozkan Ozlu我一直在抨击这个尝试,几乎每一次都可能我错过了一些小细节。祝一切顺利。 – user2303233 2013-04-21 05:01:06

+0

嗨auicsc有没有选择在哪里接受你和韦恩的答案?因为这两个解决方案都对我有帮助。 – user2303233 2013-04-21 13:47:02