Forum Moderators: coopster

Message Too Old, No Replies

script to create key field searchable directory/database

for campgrounds and the like

         

travelbuff

3:38 pm on Jun 30, 2003 (gmt 0)

10+ Year Member



Hi all:

Can anyone recommend a php+sql script that will allow me to create and manage a searchable database/directory on my site. I intend to use it for campgrounds and the like. Here is how I would like it to work:

A grounds owner can visit my site and fill out a form containing certain info that I specify (like location, number of sites, amenities, etc). I would also like a freehand description and the ability to include images.

After I approve the listing, I would like site visitors to be able to go to a search form, check off amenities they want and search the database. It would be sweet if the listings could be returned with summarized results and a more info link to see the full listing. It would be super sweet if the script included a search within so many miles of a zip code or area code.

My knowledge of php is limited but I know linux and apache and I am not afraid to do some hacking. I have a ded server with root access. I have searched sourceforge and hotscripts but nothing seemed really suited to what I want to do.

Any suggestions would be greatly appreciated!

Thanks

Mark

jatar_k

4:59 pm on Jun 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you tried looking for near match type scripts? Something like a hotel listing script or maybe even a real estate listing script and then tailoring it to your specifics?

It does sound semi custom and I don't really know of any off the top of my head.

vincevincevince

7:40 pm on Jun 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My knowledge of php is limited

If you've experience with another language, e.g. C, perl, etc. then I believe with our good friend Google to hand it'd not take you long (2/3h) to hash something together that works - and what you'll learn in those hours will save you days in the future!

the basic functions you'll need are in
[webmasterworld.com...]

the way i'd do it would be to have 1 table, and two scripts:
- table: campsites (siteid [auto increment], sitename, address, your questions ... , description....)
- scripts: owner.php, user.php

owner.php script:
use a big IF statement:


if($_REQUEST['sitename'])
{
/*
this guy has filled in the form, so enter it to the database
1 - validate his data
2 - perform mysql_escape_string() on the data, and possibly change to htmlentities or change < to &lt; etc
3 - "INSERT INTO campsites (sitename, address ... etc) VALUES ('".$_REQUEST['sitename']."','".$_REQUEST['address']."'.... etc);"
4 - tell him it's all worked out well :-)
*/
}
else
{
/*
this guy hasn't filled in he form, so give him the form to fill in, with the action going back to $PHPSELF
*/
}

for user.php:
i'd use a big switch construct


switch $_REQUEST['action']
{
default :
{
//give this guy the search form, add a hidden variable "action" which has the value "searchresults", the actual form ACTION will be $PHPSELF
break;
}
case "searchresults":
{
//here we just do a standard SELECT statement based on what data has been passed to us from the search form.
//make a loop to output all the results returned from the SELECT query
//we will want to show just summaries - so echo just those bits you want - why not use preg_replace("/[^.]*$/","",substr($description,0,300)) to trim the freehand description down to the end of the sentence closest before 300 characters?
//add some kind of READ MORE link - this will be in the form $PHPSELF?action=detail&siteid=$siteid, knowing we get the siteid from our select query!
break;
}
case "detail":
{
//we know that $_REQUEST['siteid'] has the siteid, so do a SELECT query, WHERE siteid=$siteid LIMIT 1;
//then output the data we get, pretty much like before.
break;
}
}

*code, what little there is of it, is untested