Jump to content

QuickOldCar

Staff Alumni
  • Posts

    2,972
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by QuickOldCar

  1. Once my server gets done recovering some lost files I can fiddle more with an idea I have.(been 3 days thus far) It would be them typing in either special expressions or just using the simple words of and,or,not Highlighting the word, or groups of words to show them their search terms better. Doing a preg_match on the string and seperating these into groups, query the database with all the desired results. Maybe you don't know this but +,- are default characters to include and exclude in a boolean mode search.
  2. Looking over your code again and thinking. I thought that if you place the string into an array, and make each word unique, you could then maybe do a foreach loop and modify each as you like, checking for patterns using preg_match for each word if contains spaces or the +. Then would need to trim and remove the plus...run whatever query you wanted with the words. I did come across this, it may help or just confuse the situation more. http://www.joedolson.com/Search-Engine-in-PHP-MySQL.php I would use preg_match with a pattern like /and|or/\i if needed it to work for either one Pretty much you can do anything you want here, most things can be done in php if are slick enough about it. if wanna display OR plus also AND, then run a double query, if checking for exact matches...look for double whitespace, if is an include check for the + To me I'd rather just let the user select which type of search they want, after all, they are the only ones that know what they want.
  3. I already know is gonna be piles of different advice given for this. Each person works in different ways, in ways that may work best for them. My advice is to try to make as much as can able to be removed/added or modified easily or with less effort on recoding or major changes. How that pertains to the project could vary greatly. Using functions and classes helps. As for folders, they can always be added at any time. Start small and basic and work your way up from there, eventually you will have a large project. Try to keep organized , it's horrible to not find what you need.
  4. <?php $siteA ="http://www.yoursite.com/A.html"; $siteB ="http://www.yoursite.com/B.html"; $switchtime = "2011-03-14 06:44:00"; $k = strtotime($switchtime); $t = (int)date('U') /* DEBUG */ //echo date("y-m-d h:i:s T",$k); //echo "<br/>".date("Y-m-d h:i:s T",$t); /* */ if($t<$k){ header("location: $siteA"); }else { header("location: $siteB"); } ?>
  5. well i didn't escape the last variable, but I'm guessing don't want the boundaries so left it out <?php function matchWord($word,$string){ if (preg_match("/$word/i", $string)) { $the_result = "match"; } else { $the_result = "no match"; } return $the_result; } //usage $text="Sol 3 Drawer Chests Antique Pine Bedside Chest"; $the_word = "Chest"; $is_it_there = matchWord($the_word,$text); echo $is_it_there; ?>
  6. filling out the form and clicking generate makes the code, here's an example i did. <object classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616" width="320" height="260" codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab"> <param name="custommode" value="none" /> <param name="previewImage" value="image.png" /> <param name="autoPlay" value="false" /> <param name="src" value="video.avi" /> <embed type="video/divx" src="video.avi" custommode="none" width="320" height="260" autoPlay="false" previewImage="image.png" pluginspage="http://go.divx.com/plugin/download/"> </embed> </object> <br />No video? <a href="http://www.divx.com/software/divx-plus/web-player" target="_blank">Download</a> the DivX Plus Web Player.
  7. And why not use preg_match with boundary which is the \b and the i for insensitive search? untested, but it should work <?php function matchWord($word,$string){ if (preg_match("/\$word\b/i", $string)) { $the_result = "match"; } else { $the_result = "no match"; } return $the_result; } //usage $text="Sol 3 Drawer Chests Antique Pine Bedside Chest"; $the_word = "Chest"; $is_it_there = matchWord($the_word,$text); echo $is_it_there; ?>
  8. I gave you the code generator page already. http://labs.divx.com/WebPlayerCodeGenerator
  9. You can use the divx embed to play a divx or avi file. http://labs.divx.com/WebPlayerCodeGenerator
  10. I don't see any reason to use the + or - for included and excluded terms in an exact phrase search. For my site I made a dropdown that they can select which type of search and from what areas they would like to look from. It then uses a multiple if/else for the mysql queries and I use a variety of match,like and boolean mode to get the specific type of results. Pretty much any + or - in any phrase or search word still works regardless what they selected. I'm sure doing it your way in a certain circumstance you can just do a replace. Possibly if the first character is not a number or letter then do something. $search_words = str_replace(array('+','-'), "", $search_words); Anyway, If this helps here's a snippet of my code and how I do it. I integrated my pagination, so it's like a search/navigation rolled into one. It uses the get values from the form and then is also paged by same form. I have some old queries and such, I fiddle with this more sometimes. //search get variables from search-navigation if ($search == "Date") { // $result = mysql_query("SELECT * FROM posts $post_status AND post_date LIKE //'".$search_words."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); //$total_count = mysql_query("SELECT * FROM posts $post_status AND post_date LIKE //'".$search_words."%'"); $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_date) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_date) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "ID") { $result = mysql_query("SELECT * FROM posts $post_status AND ID LIKE '".$search_words."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND ID LIKE '".$search_words."%'"); } elseif ($search == "url_begins_characters") { $result = mysql_query("SELECT * FROM posts $post_status AND post_title LIKE '".$search_words."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND post_title LIKE '".$search_words."%'"); } elseif ($search == "url_contains_characters") { $result = mysql_query("SELECT * FROM posts $post_status AND post_title LIKE '%"."$search_words"."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND post_title LIKE '%"."$search_words"."%'"); } elseif ($search == "feed_single_word") { $result = mysql_query("SELECT * FROM posts $post_status AND link_rss LIKE '%"."$search_words"."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND link_rss LIKE '%"."$search_words"."%'"); } elseif ($search == "one_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "exact_words") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "least_one_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "exclude_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_title,post_content) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE)"); } elseif ($search == "title_one_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (title_2) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (title_2) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "title_exact_words") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (title_2) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (title_2) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "title_least_one_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (title_2) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (title_2) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "title_exclude_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (title_2) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (title_2) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE)"); } elseif ($search == "description_one_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_description) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_description) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "description_exact_words") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_description) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_description) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "description_least_one_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_description) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_description) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "description_exclude_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_description) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_description) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE)"); } elseif ($search == "keyword_one_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_keywords) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_keywords) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "keyword_exact_words") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_keywords) AGAINST ('\"$search_words\"' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_keywords) AGAINST ('\"$search_words\"' IN BOOLEAN MODE)"); } elseif ($search == "keyword_least_one_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_keywords) AGAINST ('$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_keywords) AGAINST ('$search_words' IN BOOLEAN MODE)"); } elseif ($search == "keyword_exclude_word") { $result = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_keywords) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE) ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND MATCH (post_keywords) AGAINST ('+$search_words -$search_words' IN BOOLEAN MODE)"); } else { //if anything goes wrong above or nothing selected, this will be used as the default query instead /* all posts //$result = mysql_query("SELECT * FROM posts $post_status ORDER BY $display $order //LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status"); */ //just show last 10 by id main page if ($url == "http://get.blogdns.com/dynaindex/index.php") { $result = mysql_query("SELECT * FROM posts ORDER BY ID DESC LIMIT 0,10"); $total_count = $result; } else { //todays results new and updated $result = mysql_query("SELECT * FROM posts $post_status AND post_date LIKE '".$today_date."%' ORDER BY $display $order LIMIT $startrow,$posts_per_page" ); $total_count = mysql_query("SELECT * FROM posts $post_status AND post_date LIKE '".$today_date."%'"); }
  11. Everything seems to work proper and look ok. The large text message with picture, I guess that being a little smaller would help. Good Job on it.
  12. You should be able to accomplish this using GD. Here's a link in the forum with code for placing text onto an image in a circular manner. http://www.phpfreaks.com/forums/index.php?topic=317673.msg1498090#msg1498090
  13. Here's a very simple example. <?php if(!isset($_GET['link'])){ $link = "home"; } echo "<a href='?link=home'>Home</a> <a href='?link=news'>News</a> <a href='?link=bio'>Bio</a> <a href='?link=pic'>Pic</a> <a href='?link=draw'>Draw</a><p>"; if ($link == "news"){ include('news.php'); } elseif ($link == "bio"){ include('bio.php'); } elseif ($link == "pic"){ include('pic.php'); } elseif ($link == "draw"){ include('draw.php'); } else { include('home.php'); } ?> Here's a demo of it. http://get.blogdns.com/navigation/
  14. I believe that is the best way to do so, it sucks, but unless you want them there you must do that.
  15. Everything seems to work fine. You have any pagination for when you have many articles? One thing I would change is on this page http://bkgallery.site90.net/tutorials.php I'd use the same style as the main navigation uses for those sub categories.
  16. Odd, well remove the $aid = mysql_real_escape_string($_GET['aid']); and make it $aid = $_GET['aid']; see if can connect
  17. Although you can add a hidden value in a form, how would it know which category to insert into? I would think using a form and letting them select a category would be the best way to go about this. I would additionally make an uncategorized for anything not falling into your specific categories or if they didn't select anything. http://www.w3schools.com/html/html_forms.asp I think a dropdown would be the best way, takes less room on the page. http://www.w3schools.com/html/tryit.asp?filename=tryhtml_select3 Then use the value from the POST or GET for your database insert of your category
  18. One more thing, Pass your variable in a form link like so <form method=GET action='http://www.yoursite.com/script.php'> Use your values of course.
  19. Open the connection before the get. So move $aid = mysql_real_escape_string($_GET['aid']); after your $connection
  20. I just looked again, usually you assign a variable to the get and use that variable into your select statement. be sure you have the correct single quotes as well, also escape bad characters from any input $aid = mysql_real_escape_string($_GET['aid']); $query="SELECT * FROM articles WHERE id='$aid'";
  21. I just took a fast peek, could it be that you are closing mysql too early and losing your results.
  22. I made a multiple word color highlighter for my search index. Is 2 versions in code, one is for an array of words and the other explodes lines of text into an array. The code and demo is at the link. http://get.blogdns.com/dynaindex/color-highlighter.php
  23. I use curl and mysql for mine. There's actually a lot more involved as one would think there was to it. Takes lots of time to connect to all the sites just to get all the information you want from them to save. Pulling in random links from various websites, storing them, and just showing the latest discovered links by date is easier. (like a normal search engine is) I would suggest using cassandra as a database and python to do the searching of the data if wanted to do a serious search engine.
  24. you add in your queries AND now='1'
  25. you would want 2 == to do the check make this: if($arg1="lower"){ return strtolower($arg2); } elseif ($arg1="upper"){ return strtoupper($arg2); } else /* if($arg1="title")*/{ return ucwords($arg2); } into this: if($arg1=="lower"){ return strtolower($arg2); } elseif ($arg1=="upper"){ return strtoupper($arg2); } else /* if($arg1=="title")*/{ return ucwords($arg2); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.