Forum Moderators: coopster
I'm totally new to PHP, and was wondering if anyone could point to me a PHP script that I could use to have a school search website? Basically, having a search so that if they typed in "accountant", they would get all listings dynamically showing all that matched the criteria. Is PHP the way to go for this? I've searched Hot Scripts, and am not even sure what to be looking for..
Thanks for any help on this.
Brian
If you want to write your own search, then you would have to index all of your contents (usually into a database) and then write a search routine that would find things on keywords.
If this sounds like too much trouble at the moment, then do a search for Free Web Site Search Engine in your favourite search engine and you will find various offering out there. Most of the free ones of course come with some advertising on the search results page unless you go for their paid version.
I'm hoping for something where on the top right is a search bar. Type in say "springs"
This will give a list of results that have the word Springs anywhere in the text.
Thanks again
Brian
[edited by: coopster at 3:55 pm (utc) on Feb. 1, 2006]
[edit reason] removed url per TOS [webmasterworld.com] [/edit]
So if someone types in "Winnipeg", it will show all of the complete listings of any school with the word winnipeg on one page. Not a summary of a whole bunch of pages, but the actual results themselves.
Thanks
Brian
<?php
// Connecting, selecting database
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');
$search = $_POST[textboxdata];
// Performing SQL query
$query = 'SELECT $search FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>