Advertisement
chiabgigi

dropdown_image_div

Oct 18th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.03 KB | None | 0 0
  1.     <form name="emp_actor" id="emp_actor" method="post" action="" >
  2.         <div align="center">
  3.             <h2 align="center">List of 'actor1'</h2>
  4.  
  5.             <strong> Select actor : </strong>
  6.             <select name="name" id="name" onchange="onSelectChange1();">
  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.  
  17.             <div class="row col-sm-8">
  18.                 <div class="col-sm-1">Id</div>
  19.                 <div class="col-sm-4">Name</div>
  20.                 <div class="col-sm-3">BirthDay</div>
  21.                 <div class="col-sm-4">Foto</div>
  22.             </div>
  23.  
  24.         </div>
  25.         <?php
  26.         if($_SERVER['REQUEST_METHOD'] == "POST") {
  27.             $des = $_POST["name"];
  28.             if ($des == "")  // if ALL is selected in Dropdown box
  29.             {
  30.                 $res = mysqli_query($conn, "Select * from actor order by actor_id desc ");
  31.             } else {
  32.                 $res = mysqli_query($conn, "Select * from actor where name='" . $des . "'");
  33.             }
  34.  
  35.             //  echo "<tr><td colspan='5'></td></tr>";
  36.             while ($row = mysqli_fetch_array($res)) {
  37.                 echo
  38.  
  39.                     '<div class="container-fluid" align="center">
  40. <div class="row col-sm-8">
  41.        <div class="col-sm-1">'.$row['actor_id'].'</div>
  42.        <div class="col-sm-4">'.$row['name'].'</div>
  43.        <div class="col-sm-3">'.$row['birthday'].'</div>
  44.        <div class="col-sm-4"><img src="upload/' . $row['foto'] . '" height="50" width="40" class="img-thumnail" /></div>
  45.        </div></div>';
  46.          }
  47.         }
  48.         ?>
  49.     </form>
  50.  
  51.  
  52.  
  53.     <script>
  54.         function onSelectChange1() {
  55.             document.getElementById('emp_actor').submit();
  56.         }
  57.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement