Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $query = $pdo->prepare("SELECT * FROM subs WHERE sub_title LIKE '%$search%' LIMIT 0, 10");
- <?php
- require_once('includes/config.php');
- include("includes/header.php");
- // Search from MySQL database table
- $search = $_POST['search'];
- $query = $pdo->prepare("SELECT * FROM subs WHERE sub_title LIKE '%$search%' LIMIT 0, 10");
- $query->bindValue(1, "%$search%", PDO::PARAM_STR);
- $query->execute();
- // Display search result
- if(!$query->rowCount() == 0) {
- echo "Search found:<br>";
- echo "<table>";
- echo "<tr><td>Title</td><td>Category></td><td>Language</td><td>Time</td><td>Download</td></tr>";
- while($results = $query->fetch()) {
- echo "<tr><td>";
- echo $results['sub_title'];
- echo "</td><td>";
- echo $results['category'];
- echo "</td><td>";
- echo $results['sub_lang'];
- echo "</td><td>";
- echo $results['timestamp'];
- echo "</td><td>";
- echo $results['sub_data'];
- echo "</td></tr>";
- }
- echo "</table>";
- } else {
- echo "Nothing found";
- }
- ?>
- <?php
- $username = '------';
- $password = '------';
- try {
- $conn = new PDO('mysql:host=localhost;dbname=-----', $username, $password, array(
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
- ));
- }
- catch(PDOException $e) {
- echo "Failed to connect to database!" . "<br><br>";
- echo $e->getMessage();
- }
- ?>
- <form class="form-inline" action="search.php" method="POST">
- <input class="form-control" name="search" id="search" type="text" placeholder="Search">
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement