wunude0011

Untitled

Apr 17th, 2020
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 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.     <li><a href="http://localhost/lt4/registration/"><img src="home.png"></a></li>
  8.     <h2>Select Cam:</h2>
  9.      <div>
  10.     <form method="POST">
  11.     <table border="1">
  12.  
  13.  
  14.  
  15.         <thead>
  16.             <th></th>
  17.             <th>cameras</th>
  18.            
  19.         </thead>
  20.         <tbody>
  21.             <?php
  22.             include('conn.php');
  23.                 $query=mysqli_query($conn,"select * from `camera`");
  24.                 while($row=mysqli_fetch_array($query)){
  25.                     ?>
  26.                     <tr>
  27.                         <td><input type="checkbox" value="<?php echo $row['camid']; ?>" name="camid[]"></td>
  28.                         <td><?php echo $row['cameras']; ?></td>
  29.  
  30.                        
  31.                     </tr>
  32.                     <?php
  33.                 }
  34.             ?>
  35.            
  36.         </tbody>
  37.     </table>
  38.     <br>
  39.     <input type="submit" name="submit" value="Submit">
  40.     </form>
  41.     </div>
  42.     <div>
  43.         <h2>Book item:</h2>
  44.         <?php
  45.                if (isset($_POST['submit'])){
  46.  
  47.  
  48.             if(isset($_POST['camid'])){
  49.  
  50.                foreach ($_POST['camid'] as $id):
  51.  
  52.  
  53.                 $sq=mysqli_query($conn,"select * from `camera` where camid='$id'");
  54.                 $srow=mysqli_fetch_array($sq);
  55.                 echo $srow['cameras']. "<br>";
  56.  
  57.                 endforeach;
  58.             }
  59.  
  60.         }
  61.     ?>
Advertisement
Add Comment
Please, Sign In to add comment