1

誰かが私を助けてくれますか、単純な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>
4

2 に答える 2

2

これには、データ選択を送信するためのフォームが必要です。2 つの php ファイルが必要です。

1 つ目は、ラジオ ボタンのフォームを作成することです。きれいに表示するためにテーブルの要素を削除してから、2 番目のページの URL を設定しました。必要に応じて単一のページにすることもできますが、これはより簡単です。

フィードバック.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>

2 番目のページでは、最初のページから投稿したものを取得します

add.php

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

$result を使用してデータベースに保存します。幸運を

于 2013-04-20T22:48:28.063 に答える
1

単純な :

まず、テーブル タグの前に次の行を追加します。

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

2番目に、これはコードの最後にあります:

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

次に、このコードを DB に挿入することができます。

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


    $satisfaction=$_POST['satisfaction'];

     $stmt->execute();

    $stmt->close();
}
于 2013-04-20T22:49:10.287 に答える