Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Selecting Rows from MySQL Table using checkbox PHP, MySQLi</title>
- </head>
- <body>
- <h2>Select Cam:</h2>
- <div>
- <form method="POST">
- <table border="1">
- <thead>
- <th></th>
- <th>cameras</th>
- </thead>
- <tbody>
- <?php
- include('conn.php');
- $query=mysqli_query($conn,"select * from `camera`");
- while($row=mysqli_fetch_array($query)){
- ?>
- <tr>
- <td><input type="checkbox" value="<?php echo $row['camid']; ?>" name="camid[]"></td>
- <td><?php echo $row['cameras']; ?></td>
- </tr>
- <?php
- }
- ?>
- </tbody>
- </table>
- <br>
- <input type="submit" name="submit" value="Submit">
- </form>
- </div>
- <div>
- <h2>You Booked:</h2>
- <?php
- if (isset($_POST['submit'])){
- foreach ($_POST['camid'] as $id):
- $sq=mysqli_query($conn,"select * from `camera` where camid='$id'");
- $srow=mysqli_fetch_array($sq);
- echo $srow['cameras']. "<br>";
- endforeach;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement