Advertisement
chiabgigi

dropdown_image

Oct 14th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.02 KB | None | 0 0
  1. <?php include 'config.php';
  2. ?>
  3. <!DOCTYPE html>
  4. <html lang="en">
  5. <head>
  6.     <meta charset="utf-8">
  7.     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  8.     <meta http-equiv="x-ua-compatible" content="ie=edge">
  9.     <title>Actors</title>
  10.     <!-- Font Awesome -->
  11.     <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
  12.     <!-- Bootstrap core CSS -->
  13.     <link rel="stylesheet" href="css/bootstrap.min.css">
  14.  
  15.     <style>
  16.         .thumb{
  17.             height: 75px;
  18.             border: 1px solid #000;
  19.             margin: 10px 5px 0 0;
  20.         }
  21.     </style>
  22. </head>
  23. <body>
  24. <div class="container-fluid">
  25.     <div class="row">
  26.         <div align="left">
  27.             <a href="main.php"><img src="back.png"></a>
  28.         </div>
  29.     </div>
  30.     <form name="frmdropdown" method="post" action="">
  31.         <div align="center">
  32.             <h2 align="center">List of 'actor'</h2>
  33.  
  34.             <strong> Select actor : </strong>
  35.             <select name="name">
  36.                 <option value="">----ALL----</option>
  37.                 <?php
  38.                 $dd_res = mysqli_query($conn, "Select name from actor");
  39.  
  40.                 while ($row = mysqli_fetch_array($dd_res)) {
  41.                     echo "<option value='".$row['name']."'>".$row['name']."</option>";
  42.                 }
  43.                 ?>
  44.             </select>
  45.             <input type="submit" name="find" value="find"/>
  46.             <input type="reset" name="name" onclick="deleteRows('tbl', false);" value="Reset">
  47.             <br><br>
  48.  
  49.             <table  id="tbl"  border="1">
  50.                 <tr align="center">
  51.                     <th align='center' width='100'>Actor Id </th>
  52.                     <th align='center' width='100'>Name </th>
  53.                     <th align='center' width='150'>Path</th>
  54.                     <th align='center' width='80'>Avatar</th>
  55.                 </tr>
  56.  
  57.                 <?php
  58.                 if($_SERVER['REQUEST_METHOD'] == "POST") {
  59.                     $des = $_POST["name"];
  60.                     if ($des == "")  // if ALL is selected in Dropdown box
  61.                     {
  62.                         $res = mysqli_query($conn, "Select * from actor order by actor_id desc ");
  63.                     } else {
  64.                         $res = mysqli_query($conn, "Select * from actor where name='" . $des . "'");
  65.                     }
  66.  
  67.                     //  echo "<tr><td colspan='5'></td></tr>";
  68.                     while ($row = mysqli_fetch_array($res)) {
  69.                         echo '<tr>
  70.                     <td align="center" width="100">'.$row['actor_id'].'</td>
  71.                     <td align="center" width="100">'.$row['name'].'</td>
  72.                     <td align="center" width="150">'.$row['path'].'</td>
  73.                     <td align="center" width="80"><img src="data:image/jpeg;base64,'.base64_encode($row['avatar'] ).'" height="50" width="40" class="img-thumnail" /></td>  
  74.                     </tr>';
  75.                     }
  76.  
  77.                   /*  echo '<img src="'.($row['image']).'" height="50" width="40" class="img-thumnail" />';*/
  78.                 }
  79.                 ?>
  80.             </table>
  81.         </div>
  82.     </form>
  83. </div>
  84.  
  85.  
  86. <!-------- clear table ------------>
  87. <script type="text/javascript">
  88.     function deleteRows(id, toDeleteHeader) {
  89.         var obj = document.getElementById(id);
  90.         if(!obj && !obj.rows)
  91.             return;
  92.         if(typeof toDeleteHeader == 'undefined')
  93.             toDeleteHeader = false;
  94.         var limit = !!toDeleteHeader ? 0 : 1;
  95.         var rows = obj.rows;
  96.         if(limit > rows.length)
  97.             return;
  98.         for(; rows.length > limit; ) {
  99.             obj.deleteRow(limit);
  100.         }
  101.     }
  102. </script>
  103.  
  104. <!-- SCRIPTS -->
  105. <!-- JQuery -->
  106. <script src="js/jquery-3.4.1.min.js"></script>
  107. <!-- Bootstrap tooltips -->
  108. <script type="text/javascript" src="js/popper.min.js"></script>
  109. <!-- Bootstrap core JavaScript -->
  110. <script type="text/javascript" src="js/bootstrap.js"></script>
  111.  
  112. </body>
  113. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement