php - How do I store the value of my dropdownlist to mysql database? -


i've created dynamic drop down list, totally clueless how save value mysql database. please :'( have tried several methods none seems work me. these original codes.

page2.php

<?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?>  <!doctype html> <html>        <form action="page2insert.php" method="post"><br/>          <table>     <tr>         <td>* name:</td>         <td><input type="text" name="pname" style="width: 300px" ></td>     </tr>      <tr>         <td>* type</td>         <td><input type="radio" name="ptype" value="student" checked>student             <input type="radio" name="ptype" value="staff">staff (eg. lecturer)</td>     </tr>      <tr>         <td>* class:</td>         <td><input type="text" name="pclass" style="width: 200px" > if student</td>     </tr>      <tr>         <td>* vote:</td>         <td>         <?php          $result=mysqli_query($connection,"select name displayimages ");           echo '<select name="fselect">';           while($row=mysqli_fetch_array($result))          {              echo "<option value='".$row['name']."'>".$row['name'] ."</option>";          }          echo "</select>";          ?>     </tr>      <tr>         <td>* comment:</td>         <td><input type="text" name="pcomment" style="width: 300px" ></td>     </tr>      <tr>         <td><center><input type="submit"></center></td>     </tr> </table> </form> 

page2insert.php

<?php require_once("includes/connection.php"); ?> <?php require_once("includes/functions.php"); ?>  <?php $sql="insert participants(name, type, class, vote, comment) values ('$_post[pname]','$_post[ptype]','$_post[pclass]','$_post[pvote]','$_post[pcomment]')";  // executes query if (!mysqli_query($connection,$sql)) {     // die('error:'.mysqli_error()); } else {     $location="page1.php";     header("location:{$location}");     echo "1 participant added".$sql; }  // close connection mysqli_close($connection); ?> 


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -