Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="search.php" method="post" id="search">
- <div id="searchfield_div">
- <input name="search" id="searchfield" type="text" placeholder="What you looking for?">
- <input id="delete_search_button" name="delete button" type="button" value="X">
- <input id="search_button" name="search button" type="submit" value="Search">
- </div>
- </form>
- <?php
- //connection script
- $db_host = "localhost";
- $db_user = "root";
- $db_pass = "";
- $db_name = "liquihub";
- $output = '';
- @mysqli_connect("$db_host","$db_user","$db_pass","$db_name") or die("could not connect");
- //collection script
- if (isset($_POST['search'])) {
- $searchq = $_POST['search'];
- $searchq = preg_replace("#[^0-9a-z]#i","", $searchq);
- $query = mysql_query("SELECT * FROM beverage_db WHERE name LIKE '%$searchq%' OR price LIKE '%$searchq%' OR type LIKE '%$searchq%'") or die ("could not search" );
- $count = mysql_num_rows($query);
- if ($count == 0) {
- $output = 'We not stocking this particular item at present';
- }else{
- while($row = mysql_fetch_array($query)) {
- $bevname = $row['name'];
- $bevprice = $row['price'];
- $bevtype = $row['type'];
- $bevid = $row['id'];
- $output .= '<div>'.$bevname.' '.$bevprice.' '.$bevtype.'</div>';
- }
- }
- }
- ?>
- <?php print("$output");?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement