Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <?php
- $dbuser = "";
- $dbpassword = "";
- $dbhost = "localhost";
- $table = "table"; //use the results table
- $field = "term" //use the place where terms are.
- $count = 0;
- mysql_connect($dbhost,$dbuser,$dbpassword) or die("Error:" . mysql_error());
- mysql_select_db("", $con);
- $field_to_search = "field";
- if(isset($_GET['q']) && trim($_GET['q']) != '')
- {
- $var = $_GET['q'] ;
- $query = "SELECT * FROM `$account` WHERE `$field` LIKE "%$var%" ORDER BY `id`";
- $result = mysql_query($query);
- $results_num = mysql_num_rows($result);
- if($results_num = 0 || $results_num < 1)
- {
- echo "No results found,please search again.";
- }
- else{
- while ($r= mysql_fetch_array($result))
- {
- $count++;
- $id = $r["id"];
- $year = $r["year"];
- $date = $r["date"];
- $title = $r["title"];
- $description = $r["description"];
- echo "<a href=\"http://www.websiteurl/index" . $year . "/" . $id ".html\">$title</a>";
- echo $description
- echo "Result Number:" . $count;
- }
- }
- }
- else{
- ?>
- <p>Please enter a search...</p>
- <form name="search" method="GET" action="<?=$PHP_SELF?>">
- Search all the newsletters for
- <input type="text" name="q" />
- <input type="submit" name="search" value="Search" />
- </form>
- <?php
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment