1

Can someone help me please, I am trying to implement a simple php MySQL survey, but I am stuck on this, how do I store the specific selection in MySQL that users select.

How satisfied are you:

<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

2 Answers 2

2

for this what you need will need a form to submit data selection. You will need two php files

The first one is to built a form of radio buttons. I had removed table's elements for neat view then we set the URL of the second page .Can also be a single page if you want but this is more easier.

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>

In the second page we catch what we had posted from first page.

add.php

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

using $result to store in your database. Good luck

Sign up to request clarification or add additional context in comments.

Comments

1

As simple as :

1st, Add this line before the table tag:

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

2nd, this one at the end of your code:

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

Then you can have this code for inserting in the DB.

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


    $satisfaction=$_POST['satisfaction'];

     $stmt->execute();

    $stmt->close();
}

7 Comments

Thank you a billion Wayne Tun Myint, auicsc for the quick reply, Wayne
Thank you a billion Wayne Tun Myint, auicsc for the quick reply, Wayne was quick and easy, i really appreciate your help, i wish one day i help others as you do, Ozkan Ozlu i have been banging my head over this tried almost everyting maybe i missed some minor detail. All the best.
Hi auicsc is there an option where to accept your and Wayne answer ? because both of the solutions helped me.
@user2303233, no there is not. You can accept the one that helped you most :)
i accepted Wayne solution as it is the one i used. Much appreciated for your help though.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.