Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <datalist id="itemList">
- <select onchange="$('#search').val(this.value)">
- <?php
- $sql = "SELECT * ";
- $sql .= "FROM `product` ";
- $result = mysql_query( $sql );
- while ($row = mysql_fetch_array($result)){
- printf( "<option value='%s' label='%s' ></option>",
- $row['ProductName'],
- $row['UnitPrice']
- );
- }
- ?>
- </select>
- </datalist>
- <!-- Search Bar -->
- <div align='right'>
- <form method="post">
- <input type="search" name="search" results="5" sizes="large" autocomplete="off" placeholder="Search Product" list="itemList" />
- </form>
- </div>
- <?php
- if( isset( $_GET['search'] ) ){
- $sql = "SELECT * FROM `product` WHERE `ProductName` = '".$_POST['search']."' ";
- $result = mysql_query( $sql );
- while ($row = mysql_fetch_array($result)){
- printf( "Name : %s | RM : %s",
- $row['ProductName'],
- $row['UnitPrice']
- );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment