Advertisement
wunude0011

Untitled

Apr 13th, 2020
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Selecting Rows from MySQL Table using checkbox PHP, MySQLi</title>
  5. </head>
  6. <body>
  7.     <h2>Select Cam:</h2>
  8.      <div>
  9.     <form method="POST">
  10.     <table border="1">
  11.  
  12.  
  13.  
  14.         <thead>
  15.             <th></th>
  16.             <th>cameras</th>
  17.            
  18.         </thead>
  19.         <tbody>
  20.             <?php
  21.             include('conn.php');
  22.                 $query=mysqli_query($conn,"select * from `camera`");
  23.                 while($row=mysqli_fetch_array($query)){
  24.                     ?>
  25.                     <tr>
  26.                         <td><input type="checkbox" value="<?php echo $row['camid']; ?>" name="camid[]"></td>
  27.                         <td><?php echo $row['cameras']; ?></td>
  28.  
  29.                        
  30.                     </tr>
  31.                     <?php
  32.                 }
  33.             ?>
  34.            
  35.         </tbody>
  36.     </table>
  37.     <br>
  38.     <input type="submit" name="submit" value="Submit">
  39.     </form>
  40.     </div>
  41.     <div>
  42.         <h2>You Booked:</h2>
  43.         <?php
  44.             if (isset($_POST['submit'])){
  45.                 foreach ($_POST['camid'] as $id):
  46.  
  47.                
  48.                 $sq=mysqli_query($conn,"select * from `camera` where camid='$id'");
  49.                 $srow=mysqli_fetch_array($sq);
  50.                 echo $srow['cameras']. "<br>";
  51.                
  52.                 endforeach;
  53.             }
  54.         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement