CountryGirl Posted November 18, 2009 Share Posted November 18, 2009 Hi all, I am building my first PHP search database with MySQL. I have all the data entered in the correct tables (16 tables) in PHPMyAdmin/MySQL. Now I need to be able to build a search feature on my website and make it searchable. Does anyone have any suggestions on good sites that would explain some of how to do this? I'm pretty new to writing PHP and such and am not exactly sure where to start! The MySQL database tables I have figured out, it's just some of the specifics like putting the actual search and such onto the webpage. Thanks for any and all tips ! Qadoshyah Country Girl Designs Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/ Share on other sites More sharing options...
Mchl Posted November 18, 2009 Share Posted November 18, 2009 Did you try this: http://www.phpfreaks.com/tutorial/simple-sql-search ? Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960341 Share on other sites More sharing options...
CountryGirl Posted November 18, 2009 Author Share Posted November 18, 2009 I am looking at that page right now, so we'll see if this will work to get me started . Qadoshyah Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960354 Share on other sites More sharing options...
CountryGirl Posted November 18, 2009 Author Share Posted November 18, 2009 I have a question off of reading the Simple SQL Search Tutorial. It makes sense for the most part, but I still have this one question. At the part of the code below . . . am I supposed to put my information on there? Like where it says ""SELECT sid, sbody, stitle, sdescription" should that be where the information I need goes. Like it should say "SELECT name, address, account number." Or, should those places be the name of the tables in the database that the information will be pulled out of? I hope my question make sense ! If there are no errors, lets get the search going. if (count($error) < 1) { $searchSQL = "SELECT sid, sbody, stitle, sdescription FROM simple_search WHERE "; // grab the search types. $types = array(); $types[] = isset($_GET['body'])?"`sbody` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['title'])?"`stitle` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['desc'])?"`sdescription` LIKE '%{$searchTermDB}%'":''; Thanks!! Qadoshyah Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960389 Share on other sites More sharing options...
Mchl Posted November 18, 2009 Share Posted November 18, 2009 sid, sbody, stitle, sdescription are examples of column names in table, so if your column are 'name','address','account number' (don't use spaces in column names BTW) that's what you should put instead. simple_search is example of table name, so you put your table name instead. Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960396 Share on other sites More sharing options...
CountryGirl Posted November 18, 2009 Author Share Posted November 18, 2009 sid, sbody, stitle, sdescription are examples of column names in table, so if your column are 'name','address','account number' (don't use spaces in column names BTW) that's what you should put instead. simple_search is example of table name, so you put your table name instead. Okay, cool! That's what I was thinking, but just wanted to be sure. Now, if I have multiple tables that will need to be able to be searched, I just list all the table names, right? Sorry for all the questions! I've just gotta make sure I get this right . Qadoshyah Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960401 Share on other sites More sharing options...
Mchl Posted November 18, 2009 Share Posted November 18, 2009 Now, if I have multiple tables that will need to be able to be searched, I just list all the table names, right? Not exactly. It depends on how your tables relate to each other. Perhaps do the single table search first, and get to more difficult things later on Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960402 Share on other sites More sharing options...
CountryGirl Posted November 18, 2009 Author Share Posted November 18, 2009 Now, if I have multiple tables that will need to be able to be searched, I just list all the table names, right? Not exactly. It depends on how your tables relate to each other. Perhaps do the single table search first, and get to more difficult things later on Okay, I see. They all relate to each other by having a KeyID & same account number. Where would be a good place to look into doing a search from multiple tables? Thanks so much for the help! Qadoshyah Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960414 Share on other sites More sharing options...
Mchl Posted November 18, 2009 Share Posted November 18, 2009 Right here You can tell us what tables you have, and what results you would like to retrieve, and we can help you writing proper queries Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960436 Share on other sites More sharing options...
CountryGirl Posted November 18, 2009 Author Share Posted November 18, 2009 Right here You can tell us what tables you have, and what results you would like to retrieve, and we can help you writing proper queries Awesome! Thanks so much! I'll probably be on here again tomorrow asking those questions . Qadoshyah Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960460 Share on other sites More sharing options...
corbin Posted November 18, 2009 Share Posted November 18, 2009 By the way, depending on what you're doing, that search solution might be horribly slow. Using %keyword% doesn't use indexes (since any wildcard string starting with % cannot use an index). That means that for each row, the entire description will have to be scanned and compared. (It might not be all rows if other constrains are used, but it can still be bad.) If you're going to have a lot of rows or a lot of content per row, you might want to consider something else like full text searching (it has limitations too though, such as being limited to the MyISAM engine). Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960462 Share on other sites More sharing options...
Daniel0 Posted November 19, 2009 Share Posted November 19, 2009 You can also use things like Lucene or Sphinx. Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960898 Share on other sites More sharing options...
JonnoTheDev Posted November 19, 2009 Share Posted November 19, 2009 You can also use things like Lucene or Sphinx. If you are new to php/mysql then the above maybe a bit out of your depth, however Sphinx is fantastic for search functionality, especially if your database tables are using text fields and have a large number of records. Definately worth looking at when you get more confident. Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-960960 Share on other sites More sharing options...
CountryGirl Posted November 19, 2009 Author Share Posted November 19, 2009 Thanks guys for the other options. I will keep those in mind. At the moment, I'm going to play around with the Simple SQL search and see if it works for what I need it to. If not, then we'll go into something else . Qadoshyah Country Girl Designs Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-961105 Share on other sites More sharing options...
JonnoTheDev Posted November 19, 2009 Share Posted November 19, 2009 Your prices are a bit low eh? http://www.countrygirlwebdesign.com Are you a hobbyist? Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-961118 Share on other sites More sharing options...
CountryGirl Posted November 19, 2009 Author Share Posted November 19, 2009 Your prices are a bit low eh? http://www.countrygirlwebdesign.com Are you a hobbyist? Yep, pretty much. I just do it on the side . Qadoshyah Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-961123 Share on other sites More sharing options...
CountryGirl Posted November 19, 2009 Author Share Posted November 19, 2009 Alright guys, I got a search up! That tutorial is awesome - pretty easy !! This has been such a brain-wracking project . This is what I am messing with right now - http://www.wagonerassessor.com/testsearch.php. If you put in "730000001" and then check both boxes, you can pull up a record . Now, this is what I need to be able to figure out next: I have 16 tables that have data in them that I need people to be able to search. This search is being built for an Assessor's office, so the tables are thinga like, ownership (which is the table I have in the search right now), tax area, land, parcel numbers, commercial, agricultural, address, legal, sale information, etc. These tables all have their base account number and then the correct info is in each table. How do I incorporate each table into the search so that someone can access all the information they need? I need people to be able to pull up Name, Address, Account #, Parcel #, Legal, School District (tax area), Description (that'll include Sq. ft, year house was built, outbuildings, etc). Thanks for the help! You guys have been great . Qadoshyah Quote Link to comment https://forums.phpfreaks.com/topic/182054-building-a-php-search-with-mysql-script-advice-needed/#findComment-961153 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.