SHARE
TWEET

dropdown_image_table

chiabgigi Oct 18th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     <form name="frmdropdown" id="frmdropdown" method="post" action="" >
  2.         <div align="center">
  3.             <h2 align="center">List of 'actor'</h2>
  4.  
  5.             <strong> Select actor : </strong>
  6.             <select name="name" id="name" onchange="onSelectChange();">
  7.                 <option value="">----ALL----</option>
  8.                 <?php
  9.                 $dd_res = mysqli_query($conn, "Select name from actor");
  10.  
  11.                 while ($row = mysqli_fetch_array($dd_res)) {
  12.                     echo "<option value='".$row['name']."'>".$row['name']."</option>";
  13.                 }
  14.                 ?>
  15.             </select>
  16.             <input type="submit" name="find" value="find"/>
  17.             <input type="reset" name="name" onclick="deleteRows('tbl', false);" value="Reset">
  18.             <br><br>
  19.  
  20.             <table  id="tbl"  border="1">
  21.                 <tr align="center">
  22.                     <th align='center' width='100'>Actor Id </th>
  23.                     <th align='center' width='100'>Name </th>
  24.                     <th align='center' width='150'>Path</th>
  25.                     <th align='center' width='80'>Avatar</th>
  26.                 </tr>
  27.  
  28.                 <?php
  29.                 if($_SERVER['REQUEST_METHOD'] == "POST") {
  30.                     $des = $_POST["name"];
  31.                     if ($des == "")  // if ALL is selected in Dropdown box
  32.                     {
  33.                         $res = mysqli_query($conn, "Select * from actor order by actor_id desc ");
  34.                     } else {
  35.                         $res = mysqli_query($conn, "Select * from actor where name='" . $des . "'");
  36.                     }
  37.  
  38.                     //  echo "<tr><td colspan='5'></td></tr>";
  39.                     while ($row = mysqli_fetch_array($res)) {
  40.                         echo '<tr>
  41.                     <td align="center" width="100">'.$row['actor_id'].'</td>
  42.                     <td align="center" width="100">'.$row['name'].'</td>
  43.                     <td align="center" width="150">'.$row['path'].'</td>
  44.                     <td align="center" width="80"><img src="data:image/jpeg;base64,'.base64_encode($row['avatar'] ).'" height="50" width="40" class="img-thumnail" /></td>  
  45.                     </tr>';
  46.                     }
  47.  
  48.                     /*  echo '<img src="'.($row['image']).'" height="50" width="40" class="img-thumnail" />';*/
  49.                 }
  50.                 ?>
  51.             </table>
  52.         </div>
  53.     </form>
  54.  
  55.  
  56.  
  57. <!--------  form ------------>
  58. <script>
  59.     function onSelectChange() {
  60.         document.getElementById('frmdropdown').submit();
  61.     }
  62. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top