Forum Moderators: coopster

Message Too Old, No Replies

Best Script for a School Search Site?

         

gdguide

3:11 pm on Jan 31, 2006 (gmt 0)

10+ Year Member



Hi,

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

Dijkgraaf

1:10 am on Feb 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are you saying you want a search box to search all the contents of a particular site?

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.

gdguide

3:48 pm on Feb 1, 2006 (gmt 0)

10+ Year Member



Hey thank for the reply.

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]

gdguide

3:54 pm on Feb 1, 2006 (gmt 0)

10+ Year Member



Sorry. I should mention that I want results pulled from some sort of database. Not results showing different pages on the site, but all of the results on one page.

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

Moosetick

6:06 pm on Feb 1, 2006 (gmt 0)

10+ Year Member



It depends on the type of database you have. If you have a mysql database you could put a text box in a form named and do something like...

<?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);
?>