PHP - Put This In My Google Search Code.
I got this code made for me to put on my google search code.
<?php $click_value = '0.001'; //Amount in dollars that each click is worth function increment_clicks() { //Get current click count if(file_exists('click_count.txt')) $clicks = file_get_contents('click_count.txt'); else $clicks = 0; //Add current click to count $clicks++; //Save new value to file $file = fopen('click_count.txt', 'w'); fwrite($file, $clicks); fclose($file); } function get_click_amount() { global $click_value; //Get current click count if(file_exists('click_count.txt')) $clicks = file_get_contents('click_count.txt'); else $clicks = 0; //Return value of all clicks based on $click_value, formatted to 2 decimal places return number_format($clicks * $click_value, 3); } if (isset($_POST['search'])) { //Search button was clicked, increment count increment_clicks(); } $click_amount = get_click_amount(); ?> <html> <head> </head> <body> <center> <p id="click_amount">$<?php echo $click_amount; ?></p> <form action="" method="POST"> <input type="text" name="search" value="" /> <input type="submit" value="Search" /> </form> </center> </body> </html> Now i do not know how to put it in my google code if you put it on a page by itself it works. I do not know if i can list my google code here so if anyone can help i will pm them m google code. THANKS Similar TutorialsI require a page to be added to my website. This page will facilitate a refined search via Google, Bing and Yahoo search engine simultaneously , show the top 5 of each engine. Is this possible using php ? Thank's I am developing a portion of a site for a client. He has an 800 page pdf document that he would like the software to search based on client input. When the user searches, he would like it to display a Google-esque search results page that would display a title (Probably the chapter in which the result was found), then an excerpt from the text surrounding the matching keyword(s). When the user clicks the link, he would like it to take them to the page where the match was found. A big drawback is that this document will be changing fairly regularly and will need to be updated. Initially I thought I could store the pdf in a database as text/html with each page being a record in the table, but with frequent changes, I fear this would be a nightmare to manage. My only other thought is to store the file as one big entry in a table and search the entire entry, which I have done some searching and have come up with some options, but when you click it loads the entire db entry. This would create issues with an 800 page document. I have code to search a database of members, I can search by lastname but having a little problem. I want to be able to search by lastname starting with the first letter. (ie: a or b or c or d and so on). As it is right now I can only search by first letter of last name if I add % to the search (ie: a% b% c%) will give me all members with the last names starting with the approiate letter designation. I'm not sure how to handle this, any help would be appreciated. Thanks. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> </head> <body> <center><table cellspacing="10" cellpadding="10" width="750" border="0"> <h4>Search</h4> <form name="search" method="post" action="<?php $PHP_SELF?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="lname">Last Name</option> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <?php // check to see if anything is posted if (isset($_POST['find'])) {$find = $_POST['find'];} if (isset($_POST['searching'])) {$searching = $_POST['searching'];} if (isset($_POST['field'])) {$field = $_POST['field'];} //This is only displayed if they have submitted the form if (isset($searching) && $searching=="yes") { echo "<h4>Results</h4><p>"; // If they did not enter a search term we give them an error if (empty($find)) { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("localhost", "root", "1910") or die(mysql_error()); mysql_select_db("cmc_member") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); // Now we search for our search term, in the field the user specified $results = mysql_query("SELECT * FROM members WHERE upper($field) LIKE'$find'"); // And we display the results if($results && mysql_num_rows($results) > 0) { $i = 0; $max_columns = 3; while($row = mysql_fetch_array($results)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; // make sure we have a valid product ALIGN='CENTER' if($fname != "" && $fname != null) echo "<td ALIGN='CENTER'><FONT COLOR='red'><b>$fname $lname</b></FONT><br> $address <br> $city $state $zip <br>$phone<br><a href=\"mailto: $email\">$email</a><br></td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches = mysql_num_rows($results); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> </tr> </table></center> </body> </html> Hello friends, Posting this thread after many months. Well I am making a small script in which on first page there will be a text box with button. What I want to have is, When we enter any keyword, like "yahoo" in textbox and click on submit button, on next page, there should be top 10 domain names from google search. One of the most important is it should have option to select pages from specific countries like from google.co.uk or google.com or google.jp, this should be on first page. I dont know how to fetch first 10 results domain names / URL and insert it in PHP variable and populate in table. Need help I am using html5 and all the pages have h2 headings as titles. They all show up in google search results fine. The only thing that doesn't show up fine are some of the descriptions under each heading. Some meta descriptions show up fine under the correct heading title, while rest shows ALL the heading tags AS description under each search result.
For eg.
Cars
www.mywebsite.com/category?id=5&name=cars For a long time, I think I have been using heading tags wrong on websites.
They always show like this on Google.
Websitename websitename.com/category?name=mystery Posted by Night Flyer; 7 days ago; 5 views. « first; « prev; 1 of 1; next »; last ». Contact Us; @ 2014 websitename Inc. All Rights Reserved.As you can see, Google takes all the heading tags on my page and puts them in the description of the search result. So I have finally come to the conclusion that I should not be using heading tags for those things. Am I correct on that? Ok, so I have a bit of code but it's not working as it should, would one of you guys have a look at it and let me know where I'm going wrong? Basically I need to be able to input several words or terms into the text area, each on a separate line and have the results displayed something like: hello: 23,000.000 hello world: 19,000,000 world: 278,000,000 I also see that the script is not searching the words / terms inside quotes (EG. "hello world") TIA Code: [Select] <html> <body> <?php function my_fetch($url,$user_agent='Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)') { $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt ($ch, CURLOPT_HEADER, 0); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_REFERER, 'http://www.google.com/'); $result = curl_exec ($ch); curl_close ($ch); return $result; } $s = $_GET['s']; if (isset($s)) { echo "<p><i>Search for $s</i></p>"; $s = urlencode($s); $data = my_fetch("http://www.google.com/search?hl=en&q=" . $s . "&btnG=Google+Search"); $data = strip_tags($data); $find = 'Results 1 - 10 of about '; $find2 = ' for'; $data = strstr($data, $find); $pos = strpos($data, $find2); $search_number=substr($data,strlen($find), $pos-strlen($find)); echo "Total Results: $search_number"; } else { ?> <form name="form1" id="form1" method="get" action=""> <div align="left"> <p> <textarea name="s" type="text" id="s" rows="8" style="width:60%" /></textarea><br /> <input type="submit" name="Submit" value="Results" /></p> Put "" around the string: <input type="checkbox" checked name="apos" value="true" /><br /> </div> </form> <p> <?php } ?> </p> </body> </html> Hey guys im a little stumped. My pages has the following links. <a href="?page=yes">Yes</a> to Change content i use <?php if (isset($_GET['page'])) { include ("include/".$_GET['page'].".php"); } else { echo 'Welcome to Liquids Scripts PHP Code repository. Just select the categorie from the top and get all the info required '; } ?> Will this be tracked by google analytics? Any help would be awsome. Hi guys, this is the geocoding part of the code. I ran this ion my localhost and it runs ok. Then when i uploaded it to my server i got 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. When i take out the php the html code run ok... so its not that. Can anyone help? I have taken out my key and db connection. Im hosted on black knight if thats any help Code: [Select] <?php require("config.php"); define("MAPS_HOST", "maps.google.com"); define("KEY", "****"); // Opens a connection to a MySQL server $connection = mysql_connect("localhost", "root", "password"); if (!$connection) { die("Not connected : " . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db("database", $connection); if (!$db_selected) { die("Can\'t use db : " . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM users WHERE 1"; $result = mysql_query($query); if (!$result) { die("Invalid query: " . mysql_error()); } // Initialize delay in geocode speed $delay = 0; $base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" . KEY; // Iterate through the rows, geocoding each address while ($row = @mysql_fetch_assoc($result)) { $geocode_pending = true; while ($geocode_pending) { $address = $row["address1"]; $id = $row["id"]; $request_url = $base_url . "&q=" . urlencode($address); $xml = simplexml_load_file($request_url) or die("url not loading"); $status = $xml->Response->Status->code; if (strcmp($status, "200") == 0) { // Successful geocode $geocode_pending = false; $coordinates = $xml->Response->Placemark->Point->coordinates; $coordinatesSplit = explode(",", $coordinates); // Format: Longitude, Latitude, Al itude $lat = $coordinatesSplit[1]; $lng = $coordinatesSplit[0]; $query = sprintf("UPDATE users " . " SET lat = '%s', lng = '%s' " . " WHERE id = '%s' LIMIT 1;", mysql_real_escape_string($lat), mysql_real_escape_string($lng), mysql_real_escape_string($id)); $update_result = mysql_query($query); if (!$update_result) { die("Invalid query: " . mysql_error()); } } else if (strcmp($status, "620") == 0) { // sent geocodes too fast $delay += 100000; } else { // failure to geocode $geocode_pending = false; echo "Address " . $address . " failed to geocoded. "; echo "Received status " . $status . " \n"; } usleep($delay); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Your Profile Page</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/1.css" type="text/css" media="screen,projection" /> </head> <body> <div id="wrapper" class="fixed"> <div id="header"> <h1>Find A Tag Team</strong></h1> <ul id="nav"> <li><a href="home.html">Home</a></li> <li><a href="index.html"></a>Logout</li> <li><a href="Links.php">Links</a></li> <li><a href="Videos.php">Videos</a></li> </ul> </div> <div id="sidebar_left"> <h2>Your Profile Page</h2> <p> </p> <p> From here you can ...<br /> -Edit all your information <br /> -Search for other users <br /> -View any emails you may have recieved</br /> </p> <p> </p> </div> <div id="content"> <h1>Profile</h1> <div class ="message"> The map has been succesfully updated. <br /> <a href = "map.php">View the Map</div> <div id="footer"> </div> </div> </body> </html> This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=356789.0 I have a Google Adsense code that I am saving to the wp_options table. I can successfully save and retrieve the variable containing the google adsense code but it doesn't do anything except display it as plain text on screen. Hi Everyone, I have a script for a search box, it is not working as expected i need to know what to change in it safely. The search is for UK postcodes, for testing it i'm using my postcode WS122SH. The results are this: Click here to try the search on google You searched for: "ws122sh" Results for ; ws122sh ws122sh Next 10 >> Showing results 1 to of "ws122sh" I know i have WS122SH in my DB, so that IS a result, so i know that if numrows == 0 isnt working right? but not sure how to change it? i deleted it before but it caused syntax errors, any one please help. Thanks you. Code: [Select] <?PHP session_start(); include('php only scripts/db.php'); ?> <!DOCTYPE html> <head> <title>Removalspace.com</title> <style type="text/css"> <!-- body { background-image: url(styles/downloaded%20styles/todo/todo/images/bg.png); } --> </style> <link href="styles/downloaded styles/todo/todo/css/style.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/style9.css" /> <link rel="stylesheet" type="text/css" href="styles/downloaded styles/todo/todo/css/demo.css" /> <link href='http://fonts.googleapis.com/css?family=Terminal+Dosis' rel='stylesheet' type='text/css' /> <style type="text/css"> <!-- .Stile1 {color: #333333} --> </style> </head> <body> <!--start container --> <div id="container"> <header> <nav> <div id="logo"><a href="index.php"><img src="images/header2.png" alt="Logo here" width="219" height="161" /></a> </div> <div id="search-top"> <form method="post" action="search.php"> <input type="text" name="strSearch" onFocus="if(this.value=='Search')this.value='';" onBlur="if(this.value=='')this.value='Search';" value="Search" id="search-field"/> <input type="submit" value="" id="search-btn"/> </form> </div> <div id="nav_social"><a href="http://www.facebook.com/pages/Removalspace/181434181939226"><img src="styles/downloaded styles/todo/todo/images/facebook_32.png" alt="Become a fan" width="32" height="32" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/twitter_32.png" alt="Follows on Twitter" /></a><a href="#"><img src="styles/downloaded styles/todo/todo/images/linkedin_32.png" alt="Linked in" /></a><a href="contact.php"><img src="styles/downloaded styles/todo/todo/images/email_32.png" alt="Contact" width="32" height="32" /></a> </div> </nav> </header> <p><a href="removals.php">Search Removals</a></p> <p><a href="storage.php">Search Storage</a></p> <p><a href="about.php">About</a></p> <p><a href="contact.php">Contact</a></p> <div class="content"> <!--star main --> <main></main> <!--end main --> <!--start middle --> <middle> <div class="section_slogan"> <?PHP // validate postcode search function is_valid_uk_postcode($postcode) { $pattern = "/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/"; if (preg_match($pattern, $postcode)) { return TRUE; } $this->validation->set_message('is_valid_uk_postcode', 'That is not a valid %s.'); return FALSE; } $error_message = ""; if((!isset($_POST['strSearch'])) || (strlen(trim($_POST['strSearch'])) <5) || (trim($_POST['strSearch']) != preg_replace("/[^a-zA-Z0-9\_]/", "", trim($_POST['strSearch'])))) { $error_message = "You must enter a valid postcode<br>"; $error_message = $error_message . "Valid postcodes must not contain and spaces and consist of letters and numbers only.<br>"; $error_message = $error_message . 'Your invalid name was: <font color="red">' . $_POST['strSearch'] . "</font><hr>"; }else{ $postcode = mysql_real_escape_string(trim($_POST['strSearch'])); } // Get the search variable from URL $postcode_results = $_POST['strSearch']; $trimmed = trim($postcode_results); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($postcode_results)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } // Build SQL Query $query = "(SELECT postcode, company_name FROM companies WHERE postcode like '%$trimmed%') ORDER BY postcode"; // EDIT HERE and specify your table and field names for the SQL query // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here</a> to try the search on google</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $postcode_results . ""</p>";"<br>"; "<hr>"; // begin to show results set echo "<a href=\"localarea.php?var=$postcode_results\">Results for $q;</a>"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row['postcode']; $name = $row['company_name']; echo " $title" ; echo " $company_name" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$postcode_results\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$postcode_results\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> <?php echo "<a href=\"localarea.php?var=$var\">"$postcode_results"</a>";?> </div> </middle> </div> <!--end middle --> <!--start footer --> <footer> <div id="footer"></div> </footer> <!--end footer --> </div> <!--end container --> <!-- Free template distributed by http://freehtml5templates.com --> </body> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> </html> This is my SEARCH code. Code: [Select] $like = "SearchWord LIKE '%".implode("%' OR SearchWord LIKE '%", explode(' ', $Var))."%'"; $query = "SELECT * FROM db1 WHERE $like ORDER BY ToDate ASC"; $results = mysql_query($query); Currently this code search every word in the MYSQL column. (e.g. If a user enter a 3 words and hit the search button, it still take the two words as individual words and outputs all records which has either of those 3 words.) My need is to make the code find ALL the search words match in any sequence. Example: Wooden toy for 3 year old Metal sward Dora cotton pillow Wooden sward if the user search using "wooden toy" the code should show only "Wooden toy for 3 year old" if the user search using "wooden" the code should show "Wooden sward" and "Wooden toy for 3 year old" I have this code I'm using for a search: if ($xsearch) { $searchsql = mysql_escape_string($xsearch); if ($use_regex_search) { $whereA[] = "(a.adtitle RLIKE '[[:<:]]{$searchsql}[[:>:]]' OR a.addesc RLIKE '[[:<:]]{$searchsql}[[:>:]]')"; } else { $whereA[] = "(a.adtitle LIKE '%$searchsql%' OR a.addesc LIKE '%$searchsql%')"; } } So, what I want to do is to merge a.adtitle and a.addesc, so they become one value, let's say a.admerged or $admerged, I really don't know which one is possible, so the above code should look like this: if ($xsearch) { $searchsql = mysql_escape_string($xsearch); if ($use_regex_search) { $whereA[] = "(a.merged RLIKE '[[:<:]]{$searchsql}[[:>:]]')"; } else { $whereA[] = "(a.merged LIKE '%$searchsql%')"; } } The DB structure, regarding those two values, is like this: In the same table, named ads, there are those two rows, named adtitle and addesc, from which the adtitle contains the Ad Title text of the ad, and the addesc contains the Ad Description text of the ad. So, my idea is to merge those two texts in some new variable, so the search function should see those two texts as a one whole text, not checking them one by one, like it does now with the first code above. Here is one example, just to simplify my explanation: Ad Title: nokia phone on sale Ad Description: brand new, unpacked, with 16gb memory card included. Ad Merged: nokia phone on sale brand new, unpacked, with 16gb memory card included. While merged, it should have empty spece between them. I'm working to improve the search function, to search by phrase, by words, etc, and I need to solve this merging thing first, in order to continue. So, any help is appreciated. The original file with the above code is attached to this post. Thanks to all of you in advance. this is the creation table code.the database is testing. Code: [Select] CREATE TABLE users (fname VARCHAR(30), lname VARCHAR(30), info BLOB); INSERT INTO users VALUES ( "Jim", "Jones", "In his spare time Jim enjoys biking, eating pizza, and classical music" ), ( "Peggy", "Smith", "Peggy is a water sports enthusiast who also enjoys making soap and selling cheese" ),( "Maggie", "Martin", "Maggie loves to cook itallian food including spagetti and pizza" ),( "Tex", "Moncom", "Tex is the owner and operator of The Pizza Palace, a local hang out joint" ) the html code: Code: [Select] <h2>Search</h2> <form name="search" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="fname">First Name</option> <Option VALUE="lname">Last Name</option> <Option VALUE="info">Profile</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> the search code: Code: [Select] <?php if ($searching =="yes") { echo "<h2>Results</h2><p>"; if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } mysql_connect("localhost", "root", "123") or die(mysql_error()); mysql_select_db("database_name") or die(mysql_error()); $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); while($result = mysql_fetch_array( $data )) { echo $result['fname']; echo " "; echo $result['lname']; echo "<br>"; echo $result['info']; echo "<br>"; echo "<br>"; } $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } echo "<b>Searched For:</b> " .$find; } ?> I need some help with a php code I made for a search engine which I will use on my site, but an error code comes up please help me im ok at php but i need some pointers on my code! CODE: Code: [Select] <?php $button = $GET_['submit']; $search = $GET_['search']; if (!$button) echo "Please enter a keyword!"; else { if (strlen($search)<2) echo "search term to short" else { echo "you searched for $search <hr size='1'>" } mysql_connect("ftp.gpcoin.monkeyserve.com","seanhall_seanhall","81834567"); mysql_select_db("seanhall_search"); $search_exploded = explode(" ",$search) foreach($search_exploded as $search_each) { $x++; if ($x==1) $construct .= "keywords LIKE '%$search_each%'"; else $construct .= " OR keywords LIKE '%$search_each%'"; } $construct = "SELECT * FROM searchengine WHERE $construct"; echo $construct; $run = mysql_query($construct); $found = mysql_num_rows($run) if ($found==0) echo "No results Found."; else { echo "$foundnum results found!<p>"; while ($runrows = mysql_fetch_assoc($run)) { $title = $runrows['title']; $desc = $runrows['description']; $url = $runrows['url'] echo " <b>$title</b><br> $desc<br> <a herf='$url'>$url</a><br> "; } } } ?> error: Parse error: syntax error, unexpected T_ELSE, expecting ',' or ';' in /home/seanhall/public_html/search.php on line 11 Help Ok, I have the code below and it only searches one keyword of my database please could you tell me how I can search multiple keywords? <? /* * search.php * * Script for searching a datbase populated with keywords by the * populate.php-script. */ print "<html><head><title>[Squashy] Search! NOT MESSED UP.</title></head><body>\n"; if( $_POST['keyword'] ) { /* Connect to the database: */ mysql_pconnect("mysql3.000webhost.com","a4580813_dba","censored") or die("ERROR: Could not connect to database!"); mysql_select_db("a4580813_db"); /* Get timestamp before executing the query: */ $start_time = getmicrotime(); /* Execute the query that performs the actual search in the DB: */ $result = mysql_query(" SELECT p.page_url AS url, COUNT(*) AS occurrences FROM page p, word w, occurrence o WHERE p.page_id = o.page_id AND w.word_id = o.word_id AND w.word_word = \"".$_POST['keyword']."\" GROUP BY p.page_id ORDER BY occurrences DESC LIMIT ".$_POST['results'] ); /* Get timestamp when the query is finished: */ $end_time = getmicrotime(); /* Present the search-results: */ print "<h2>[Squashy] Search Results For '".$_POST['keyword']."':</h2>\n"; for( $i = 1; $row = mysql_fetch_array($result); $i++ ) { print "$i. <a href='".$row['url']."'>".$row['url']."</a>\n"; print "(occurrences: ".$row['occurrences'].")<br><br>\n"; } /* Present how long it took the execute the query: */ print "This search took: ".(substr($end_time-$start_time,0,5))." seconds."; } else { /* If no keyword is defined, present the search-page instead: */ print "<form method='post'>[Squashy Search] <input type='text' size='20' name='keyword'>\n"; print "Results: <select name='results'><option value='5'>5</option>\n"; print "<option value='10'>10</option><option value='15'>15</option>\n"; print "<option value='20'>20</option></select>\n"; print "<input type='submit' value='Search [Squashy]'></form>\n"; } print "</body></html>\n"; /* Simple function for retrieving the currenct timestamp in microseconds: */ function getmicrotime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } ?> Thanks Please help Soon! Hi there, new to the forum
Ok so i have a crm and i'm trying to add bits, been pretty succesful at most of it, however i've added a new field "status" and i want to be able to search this field, i've tried copying and changing the existing code, but it doesn't seem to be grabbing it.
So here's some exisiting code (that works and searches the field marked "Address"
'address' => array( 'title' => _l('Address:'), 'field' => array( 'type' => 'text', 'name' => 'search[address]', 'value' => isset($search['address'])?$search['address']:'', 'size' => 15, ) ), 'status' => array( 'title' => _l('Status:'), 'field' => array( 'type' => 'text', 'name' => 'search[status]', 'value' => isset($search['status'])?$search['status']:'', 'size' => 15, ) ),I thought a simple name change like above would work, but it doesn't pull anything through, anyone got any ideas? |