php - Create a table from and SQL database containing a drop down menu with a list of names from another SQL table -


i need create table drop down menu , submit button in each row. drop down menu contains list of advisers sql table. when select , adviser , press submit button id of item in current row along selected adviser id or name must sent page. in case sent delete.php.

my code bellow displays drop down menu , submit button each row of table, when press submit button work correctly if press submit button located @ bottom of table, if press other appears not send info drop down menu.

( know code appear messy, experimenting if unclear ask me , clarify. ) thank much!

<!doctype html> <html> <body>  <?php     //this code qeue // connect database udinh sqli $con = get_sqli(); // results database  if (!$con) {     die('could not connect: ' . mysqli_error($con)); } //select whole list of students walk_in mysqli_select_db($con,"login"); $sql="select * walk_in"; $result = mysqli_query($con,$sql);  if (!$result) {     printf("error: %s\n", mysqli_error($con));     exit(); } mysqli_close($con); //table dispaly qeueu of students echo "<table border='1' cellpadding='10'>";  echo "<tr> <th>id</th> <th>first name</th> <th>last name</th><th>advisor student wants see</th><th>p id</th><th>select advisor notify on send</th><th>send student</th><th> </tr>";  echo "<tr>";  //create table of students displaying data result , adding button while($row = mysqli_fetch_array($result)) {     echo "<tr>";     echo "<td>" . $row['id'] . "</td>";     echo "<td>" . $row['firstname'] . "</td>";     echo "<td>" . $row['lastname'] . "</td>";     echo "<td>" . $row['advisor'] . "</td>";     echo "<td>" . $row['pid'] . "</td>";    // echo '<form action="delete.php?id2=' . $row['id'] . '" method="post">';     // drop down menu selecting advisor form submission      // used name each submit button id walk_in     $formid =  $row['id'] ;    echo "<td>" ;  //create form submit sleected advisor , seelcted student removed queue  echo '<form action="delete.php?id=' . $row['id'] . '" method="post">';   //another query used retreive list of advisors  pupulate drop down menu  //create drop down menu advisors resulting queue echo '<select name="formstatus">'; $con = get_sqli();             mysqli_select_db($con,"login"); $sql="select * login_details level = 0 , logged = 1"; $result2 = mysqli_query($con,$sql);  if (!$result2) {     printf("error: %s\n", mysqli_error($con));     exit(); }              //loops through advisors drop down menu creation                while ($row2 = mysqli_fetch_array($result2)) {                    $id = $row2['id'];    echo '<option value="'.$id.'">'.$id.'</option>'; } echo'<option selected="selected"></option>';  echo '</select>'; echo '<td><input type="submit" name="formsubmit" value= "'.$formid.'" /><td>'; //echo '<td><input type="submit" name="formsubmit" value=  /><td>'; //echo '<td><a href="delete.php?id=' . $row['id'] . '&advisor='. "lol" .'">send</a></td>'; echo "</tr>";  } // close table> echo "</table>";   ?>  <p><a href="new.php">add new record</a></p>    </body> </html> 

here tables using:

enter image description here

login_details table containing adviser details

enter image description here

i forgot close form, issue has been fixed. thank all!


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -