Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="page-wrap">
- <?php
- //if we got something through $_POST
- if (isset($_POST['search'])) {//load database connection
- $host = "XXXXXX";
- $user = "XXXXXX";
- $password = "XXXXXX";
- $database_name = "XXXXXX";
- $pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
- ));
- // Search from MySQL database table
- $search=$_POST['search'];
- $query = $pdo->prepare("SELECT itemname, itemprice, itemupdate FROM pricedata WHERE itemname LIKE '%" . $search . "%' ORDER BY itemprice DESC LIMIT 15");
- $query->bindValue(1, "%$search%", PDO::PARAM_STR);
- $query->execute();
- // Display search result
- if (!$query->rowCount() == 0) {
- echo "<table class=\"table-fill\">";
- echo "<thead>";
- echo "<tr>";
- echo "<th class=\"text-left\">Name and wear</th>";
- echo "<th class=\"text-left\">Price</th>";
- echo "<th class=\"text-left\">Update</th>";
- echo "</tr>";
- echo "</thead>";
- while ($results = $query->fetch()) {
- echo "<tbody class=\"table-hover\">";
- echo "<tr><td align=\"left\">";
- echo $results['itemname'];
- echo "</td><td align=\"center\">";
- echo $results['itemprice'];
- echo "</td><td align=\"center\">";
- echo $results['itemupdate'];
- echo "</td></tr>";
- }
- echo "</tbody>";
- echo "</table>";
- } else {
- echo 'Nothing found';
- }
- }
- ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement