yuhsing

Untitled

Jul 17th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1.  
  2. <datalist id="itemList">
  3. <select onchange="$('#search').val(this.value)">
  4. <?php
  5.  
  6. $sql = "SELECT * ";
  7. $sql .= "FROM `product` ";
  8. $result = mysql_query( $sql );
  9.  
  10. while ($row = mysql_fetch_array($result)){
  11. printf( "<option value='%s' label='%s' ></option>",
  12. $row['ProductName'],
  13. $row['UnitPrice']
  14. );
  15.  
  16. }
  17. ?>
  18. </select>
  19. </datalist>
  20.  
  21.  
  22. <!-- Search Bar -->
  23. <div align='right'>
  24. <form method="post">
  25. <input type="search" name="search" results="5" sizes="large" autocomplete="off" placeholder="Search Product" list="itemList" />
  26. </form>
  27. </div>
  28.  
  29.  
  30. <?php
  31. if( isset( $_GET['search'] ) ){
  32.  
  33. $sql = "SELECT * FROM `product` WHERE `ProductName` = '".$_POST['search']."' ";
  34. $result = mysql_query( $sql );
  35.  
  36. while ($row = mysql_fetch_array($result)){
  37. printf( "Name : %s | RM : %s",
  38. $row['ProductName'],
  39. $row['UnitPrice']
  40. );
  41. }
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment