<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<?php include 'func.inc.php'; ?>
<title>SEARCH</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>SEARCH</h2>
<form action="" method="post">
<p>
<input type="text" name="keywords"/> <input type="submit" value="Search"/>
</p>
</form>
<?php
if (isset ($_POST['keywords'])){
$suffix ="";
$keywords =mysql_real_escape_string(htmlspecialchars(trim($_POST['keywords'])));
$keywords =$_POST['keywords'];
$errors = array ();
if (empty ($keywords)){
$errors[] = ('Please enter a serch terms');
}else if (strlen($keywords)<3){
$errors[] = ('Your search terms must be three or more characters');
}else if (search_results ($keywords) == false){
$errors []= ('Your search for '.$keywords.' returned no results');
}
if(empty($errors)) {
$results=search_results ($keywords);
$results_num = count ($results);
$suffix = ($results_num!=1) ? 's' : '' ;
echo '<p>Your search for <strong>', $keywords, '</strong> returned <strong>', $results_num, '</strong> result', $suffix, '</p>';
foreach ($results as $result) {
echo '<p><strong>', $result ['title'], '</strong> <br> ', $result['description'], '... <br> <a href="',$result['url'],'"target="_blank">',$result['url'],'</a></p>';
}
}else {
foreach ($errors as $error){
echo $error,'</br>';
}
}
}
?>
</body>
</html>
andyy121 -9 Junior Poster
andyy121 -9 Junior Poster
andyy121 -9 Junior Poster
andyy121 -9 Junior Poster
LastMitch
Squidge commented: well said :) +4
andyy121 -9 Junior Poster
LastMitch
theHop 18 Newbie Poster
andyy121 -9 Junior Poster
theHop 18 Newbie Poster
andyy121 -9 Junior Poster
happygeek commented: try growing up and accepting help from others without acting like a three year old whose toys have been taken away -2
Squidge 101 Newbie Poster
LastMitch commented: I agree +3
theHop 18 Newbie Poster
LastMitch commented: Right on Target! +3
LastMitch
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.