Well, I'm trying to make search script that's able to search through my database and display the result.
PHP Code:
mysql_connect("localhost","root","password");
Is to connect to my database yeah, and I selected my table..
PHP Code:
mysql_query("SELECT * FROM user WHERE name LIKE '%".$name."%' ") or die(mysql_error());
The '%".$name."%' was suppose to be extracted from the form.. (Not sure if this is right)
Code:
$name = $_POST["name"];
<form name="form" action="search.php" method="get">
<input name="name" type="text">
<input type="submit" name="search" value="Search">
</form>
It's like, I've this form for my users to type their keyword for searching in, then when they submit, the result will be displayed using the GET method.
Code:
if($name==NULL) {
echo("Please enter keywords to begin your search
<meta http-equiv=\"Refresh\" content=\"3; URL=search.php\">");
}else{
echo("$name was successfully search!
<meta http-equiv=\"Refresh\" content=\"3; URL=search.php\">");
}
This was added myself, which I've learnt from adding users into my database. If there's no value on the input=name, then it will display "Please enter keywords to begin your search" and autorefresh back to the main page.
But, if there's a value found, it will then say "$name (as in the value submitted) was successfully search!", which I wanna change it to display the result.
I know I'm getting more and more complicated, but yeah, simply I just need a form, then when my user type some search keywords and submit it, the result will then be shown. Like what I said on my first post, I need to be able to customize the result page too.
EDIT: Answering to your question, no I wanna it to be all at the same page, for easier editing.
Bookmarks