PHP - Refined Search Via Google, Bing And Yahoo Search Engine Simultaneously
I 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 Similar TutorialsFor 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? I want to know how to display results from mysql database by filling in a form. but i have found a tutorial which shows typing in a text box which displays results. if i follow this tutorial will it help me to understand and create php coding to display results for my form? Hello, Does anyone know a tutorial I can follow to create my own search engine over the items I have in my SQL database? I find a lot of tutorials but they are all 'one word searches' which means if you type two words you will get all results that contain either word (too many hits). If the search engine tutorial displays result with AJAX even better. Thanks for help. df Friends, I want to extract the Search Keyword from the URL, a visitor came from. I am using a PHP CMS and want to show the Keyword on my Blog. So if they search "abcd" from google, i want to extract "abcd" and echo on my blog. Here is the coding i could got hold of, but its not working, not echoing anything <?php function pk_stt2_function_get_delimiter($ref) { $search_engines = array('google.com' => 'q', 'go.google.com' => 'q', 'images.google.com' => 'q', 'video.google.com' => 'q', 'news.google.com' => 'q', 'blogsearch.google.com' => 'q', 'maps.google.com' => 'q', 'local.google.com' => 'q', 'search.yahoo.com' => 'p', 'search.msn.com' => 'q', 'bing.com' => 'q', 'msxml.excite.com' => 'qkw', 'search.lycos.com' => 'query', 'alltheweb.com' => 'q', 'search.aol.com' => 'query', 'search.iwon.com' => 'searchfor', 'ask.com' => 'q', 'ask.co.uk' => 'ask', 'search.cometsystems.com' => 'qry', 'hotbot.com' => 'query', 'overture.com' => 'Keywords', 'metacrawler.com' => 'qkw', 'search.netscape.com' => 'query', 'looksmart.com' => 'key', 'dpxml.webcrawler.com' => 'qkw', 'search.earthlink.net' => 'q', 'search.viewpoint.com' => 'k', 'mamma.com' => 'query'); $delim = false; if (isset($search_engines[$ref])) { $delim = $search_engines[$ref]; } else { if (strpos('ref:'.$ref,'google')) $delim = "q"; elseif (strpos('ref:'.$ref,'search.atomz.')) $delim = "sp-q"; elseif (strpos('ref:'.$ref,'search.msn.')) $delim = "q"; elseif (strpos('ref:'.$ref,'search.yahoo.')) $delim = "p"; elseif (preg_match('/home\.bellsouth\.net\/s\/s\.dll/i', $ref)) $delim = "bellsouth"; } return $delim; } /** * retrieve the search terms from search engine query * */ function pk_stt2_function_get_terms($d) { $terms = null; $query_array = array(); $query_terms = null; $query = explode($d.'=', $_SERVER['HTTP_REFERER']); $query = explode('&', $query[1]); $query = urldecode($query[0]); $query = str_replace("'", '', $query); $query = str_replace('"', '', $query); $query_array = preg_split('/[\s,\+\.]+/',$query); $query_terms = implode(' ', $query_array); $terms = htmlspecialchars(urldecode(trim($query_terms))); return $terms; } /** * get the referer * */ function pk_stt2_function_get_referer() { if (!isset($_SERVER['HTTP_REFERER']) || ($_SERVER['HTTP_REFERER'] == '')) return false; $referer_info = parse_url($_SERVER['HTTP_REFERER']); $referer = $referer_info['host']; if(substr($referer, 0, 4) == 'www.') $referer = substr($referer, 4); return $referer; } $referer = pk_stt2_function_get_referer(); if (!$referer) return false; $delimiter = pk_stt2_function_get_delimiter($referer); if( $delimiter ){ $term = pk_stt2_function_get_terms($delimiter); } echo $term; ?> May someone help? Natasha T I have successfully used the Yahoo local search API and received results in XML format. I am trying to use PHPs Simple XML to parse the data into an array so I can loop through and print specific elements. I cannot get to specific elements and I have read several threads online. Below is some code and below that is the XML. I am trying to get to the elements like title, address, etc. Code: [Select] $url = 'http://local.yahooapis.com/LocalSearchService/V3/localSearch?appid=<my yahoo api key>&category=Casinos&query=blackjack&zip=95035&radius=20&results=10'; $xml = file_get_contents($url); $phpobject = simplexml_load_string($xml); foreach($phpobject->attributes() as $name=>$attr) { $res[$name]=$attr; } Code: [Select] <ResultSet xsi:schemaLocation="urn:yahoo:lcl http://local.yahooapis.com/LocalSearchService/V3/LocalSearchResponse.xsd" totalResultsAvailable="48" totalResultsReturned="10" firstResultPosition="1"> − <ResultSetMapUrl> http://maps.yahoo.com/broadband/?q1=Milpitas%2C+CA+95035&tt=poker&tp=1 </ResultSetMapUrl> − <Result id="34179399"> <Title>Bay Area Poker Chip</Title> <Address>1274 Piper Dr</Address> <City>Milpitas</City> <State>CA</State> <Phone>(408) 263-8611</Phone> <Latitude>37.412359</Latitude> <Longitude>-121.891794</Longitude> − <Rating> <AverageRating>5</AverageRating> <TotalRatings>1</TotalRatings> <TotalReviews>1</TotalReviews> <LastReviewDate>1198993183</LastReviewDate> − <LastReviewIntro> I bought 100% real clay chips from here and obsolutely love it. I had a poker game that night and needed chips and a table. They had everything in stock and saved me time to look around. Great products and great service and I highly recommend this place to anybody </LastReviewIntro> </Rating> <Distance>1.33</Distance> − <Url> http://local.yahoo.com/info-34179399-bay-area-poker-chip-milpitas </Url> − <ClickUrl> http://local.yahoo.com/info-34179399-bay-area-poker-chip-milpitas </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1274+Piper+Dr+Milpitas+CA&gid1=34179399 </MapUrl> <BusinessUrl>http://bayareapokerchip.com/</BusinessUrl> <BusinessClickUrl>http://bayareapokerchip.com/</BusinessClickUrl> − <Categories> <Category id="96928631">Graphic Design</Category> </Categories> </Result> − <Result id="44540748"> <Title>Bay Area Poker Chip</Title> <Address>519 Montague Expy</Address> <City>Milpitas</City> <State>CA</State> <Phone>(408) 263-8611</Phone> <Latitude>37.409925</Latitude> <Longitude>-121.89489</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>1.48</Distance> − <Url> http://local.yahoo.com/info-44540748-bay-area-poker-chip-milpitas </Url> − <ClickUrl> http://local.yahoo.com/info-44540748-bay-area-poker-chip-milpitas </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=519+Montague+Expy+Milpitas+CA&gid1=44540748 </MapUrl> <BusinessUrl>http://www.bayareapokerchip.com/</BusinessUrl> <BusinessClickUrl>http://www.bayareapokerchip.com/</BusinessClickUrl> − <Categories> <Category id="96925976">Sporting Goods</Category> <Category id="96935378">Games</Category> </Categories> </Result> − <Result id="67710717"> <Title>Poker Da Vinci</Title> <Address>51 E Campbell Ave</Address> <City>Campbell</City> <State>CA</State> <Phone>(408) 866-4446</Phone> <Latitude>37.287157</Latitude> <Longitude>-121.94942</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>10.40</Distance> − <Url> http://local.yahoo.com/info-67710717-poker-da-vinci-campbell </Url> − <ClickUrl> http://local.yahoo.com/info-67710717-poker-da-vinci-campbell </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=51+E+Campbell+Ave+Campbell+CA&gid1=67710717 </MapUrl> <Categories/> </Result> − <Result id="21599986"> <Title>Bay 101 Banquet Facilities</Title> <Address>1801 Bering Dr</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 451-8888</Phone> <Latitude>37.373044</Latitude> <Longitude>-121.912125</Longitude> − <Rating> <AverageRating>4</AverageRating> <TotalRatings>2</TotalRatings> <TotalReviews>2</TotalReviews> <LastReviewDate>1200040214</LastReviewDate> − <LastReviewIntro> If youre looking for high limit action Bay 101 is the place to go in San Jose. You can regularly find limit games up to $80-$160 in their spacious high ceiling room. </LastReviewIntro> </Rating> <Distance>4.13</Distance> − <Url> http://local.yahoo.com/info-21599986-bay-101-banquet-facilities-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-21599986-bay-101-banquet-facilities-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1801+Bering+Dr+San+Jose+CA&gid1=21599986 </MapUrl> <BusinessUrl>http://bay101.com/</BusinessUrl> <BusinessClickUrl>http://bay101.com/</BusinessClickUrl> − <Categories> <Category id="96929273">Casinos</Category> </Categories> </Result> − <Result id="21401964"> <Title>Thwart Poker Incorporated</Title> <Address>525 Lincoln Ave</Address> <City>Palo Alto</City> <State>CA</State> <Phone>(650) 329-9627</Phone> <Latitude>37.444049</Latitude> <Longitude>-122.151513</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>14.09</Distance> − <Url> http://local.yahoo.com/info-21401964-thwart-poker-incorporated-palo-alto </Url> − <ClickUrl> http://local.yahoo.com/info-21401964-thwart-poker-incorporated-palo-alto </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=525+Lincoln+Ave+Palo+Alto+CA&gid1=21401964 </MapUrl> − <Categories> <Category id="96926908">Internet Access Providers</Category> <Category id="96932773">Computer Business Solutions</Category> </Categories> </Result> − <Result id="21574436"> <Title>Blinky's Can't Say Lounge</Title> <Address>1031 Monroe St</Address> <City>Santa Clara</City> <State>CA</State> <Phone>(408) 985-7201</Phone> <Latitude>37.348893</Latitude> <Longitude>-121.94816</Longitude> − <Rating> <AverageRating>5</AverageRating> <TotalRatings>3</TotalRatings> <TotalReviews>3</TotalReviews> <LastReviewDate>1228667811</LastReviewDate> − <LastReviewIntro> Good drinks good prices good people. Who could ask for more..... </LastReviewIntro> </Rating> <Distance>6.39</Distance> − <Url> http://local.yahoo.com/info-21574436-blinky-s-can-t-say-lounge-santa-clara </Url> − <ClickUrl> http://local.yahoo.com/info-21574436-blinky-s-can-t-say-lounge-santa-clara </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1031+Monroe+St+Santa+Clara+CA&gid1=21574436 </MapUrl> − <Categories> <Category id="96926057">All Bars, Pubs, & Clubs</Category> <Category id="96926063">Bars & Pubs</Category> </Categories> </Result> − <Result id="21619987"> <Title>Barbara of Pauline's Cake Decorating Supplies</Title> <Address>1093 Malone Rd</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 978-9740</Phone> <Latitude>37.293702</Latitude> <Longitude>-121.889876</Longitude> − <Rating> <AverageRating>4.5</AverageRating> <TotalRatings>8</TotalRatings> <TotalReviews>8</TotalReviews> <LastReviewDate>1268173462</LastReviewDate> − <LastReviewIntro> I love this store. No matter what it is i am looking for weather it is some thing i remember from my child hood or some thing i saw in a magazine and i need it i know i can find it there. Yes they are a little rough around the edges but that is only because they are trying to get it across to you what will work and what will not. This is an old school store with people who know their stuff and are only trying to help you get the best end result possible. I am 46 years old and i took my class from Barbara when i first came out of high school and believe me she will not try to up sale you or tell you some thing is going to work if it will not. Go in expecting to be overwhelmed by stock and know you are going to get the best prices in town. Take the time to get to know the employees and the store and you will always go back to Paulines. I travel all the way from Livermore to get stuff i know i can only find there. Thanks for all your many years of being in business </LastReviewIntro> </Rating> <Distance>9.52</Distance> − <Url> http://local.yahoo.com/info-21619987-barbara-of-pauline-s-cake-decorating-supplies-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-21619987-barbara-of-pauline-s-cake-decorating-supplies-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1093+Malone+Rd+San+Jose+CA&gid1=21619987 </MapUrl> − <Categories> <Category id="96928859">Wedding Supplies & Services</Category> </Categories> </Result> − <Result id="21602089"> <Title>Carey David Incorporated</Title> <Address>1624 Remuda Ln</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 453-7843</Phone> <Latitude>37.372385</Latitude> <Longitude>-121.908305</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>4.13</Distance> − <Url> http://local.yahoo.com/info-21602089-carey-david-incorporated-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-21602089-carey-david-incorporated-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=1624+Remuda+Ln+San+Jose+CA&gid1=21602089 </MapUrl> <BusinessUrl>http://dc-enterprises.com/</BusinessUrl> <BusinessClickUrl>http://dc-enterprises.com/</BusinessClickUrl> − <Categories> <Category id="96928508">Clothing Wholesalers</Category> <Category id="96928509">Clothing Manufacturers</Category> <Category id="96931030">Apparel Manufacturing</Category> </Categories> </Result> − <Result id="30246475"> <Title>Royal Casino Parties</Title> <Address>943 Berryessa Rd, #6</Address> <City>San Jose</City> <State>CA</State> <Phone>(408) 213-0904</Phone> <Latitude>37.363563</Latitude> <Longitude>-121.886341</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>4.71</Distance> − <Url> http://local.yahoo.com/info-30246475-royal-casino-parties-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-30246475-royal-casino-parties-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=943+Berryessa+Rd%2C+%236+San+Jose+CA&gid1=30246475 </MapUrl> <BusinessUrl>http://www.royalcasinoparties.com/</BusinessUrl> <BusinessClickUrl>http://www.royalcasinoparties.com/</BusinessClickUrl> − <Categories> <Category id="96925812">Entertainment Production</Category> <Category id="96930362">Gambling</Category> </Categories> </Result> − <Result id="25247620"> <Title>Bay Casino Gaming, Casino Party Rentals</Title> <Address/> <City>San Jose</City> <State>CA</State> <Phone>(408) 747-1977</Phone> <Latitude>37.338475</Latitude> <Longitude>-121.885794</Longitude> − <Rating> <AverageRating>NaN</AverageRating> <TotalRatings>0</TotalRatings> <TotalReviews>0</TotalReviews> <LastReviewDate/> <LastReviewIntro/> </Rating> <Distance>6.44</Distance> − <Url> http://local.yahoo.com/info-25247620-bay-casino-gaming-casino-party-rentals-san-jose </Url> − <ClickUrl> http://local.yahoo.com/info-25247620-bay-casino-gaming-casino-party-rentals-san-jose </ClickUrl> − <MapUrl> http://maps.yahoo.com/maps_result?q1=+San+Jose+CA&gid1=25247620 </MapUrl> <BusinessUrl>http://www.baycasinogaming.com/</BusinessUrl> <BusinessClickUrl>http://www.baycasinogaming.com/</BusinessClickUrl> − <Categories> <Category id="96925812">Entertainment Production</Category> <Category id="96925814">Party Rentals</Category> </Categories> </Result> </ResultSet> Hi, I have a script which searches the MySQL database. It outputs the result which is a business name, but I need the business name to be in a link so the user can click on it and go to another page to find out more information. However the business name is not included in the link, but the $value is.
Here is my script
<?php include 'init.php'; // normal search $result_tb = ""; if (!empty($_POST['SEARCH']) && !empty($_POST['search_value'])) { $e = $_POST['search_value']; $query = 'SELECT aquaticCenterName FROM reviews WHERE ' . "aquaticCenterName LIKE '%$e%' OR " . "town LIKE '%$e%' OR " . "county LIKE '%$e%' OR " . "country LIKE '%$e%' OR " . "rating LIKE '%$e%' "; $query_result = $con->query($query); $result_tb = '<div>'; while ($rows = $query_result->fetch_assoc()) { foreach ($rows as $k => $v) { $result_tb .= '<a href="reviewResults.php?aquaticCenterName= . $v . ">' . $v . '</a><br>'; } } $result_tb .='</div><hr>'; $con->close(); } ?> <?php include 'includes/overall/header.php'; include 'includes/logo.php'; ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table> <tr> <td> <input type="text" name="search_value" size="30" maxlength="30"/> </td> <td> <input type="submit" name="SEARCH" value="Search"/> </td> </tr> </table> </form> <?php echo $result_tb; ?> <?php include 'includes/overall/footer.php';But when I click on the link, I get this in the address bar reviewResults.php?aquaticCenterName=%20.%20$v%20. How do I get this to read eg, reviewResults.php?aquaticCenterName=PaulsAquaticCenter Many Thanks aquaman I thinking about building a search engine just as a fun project and a way to develop my skills. However I'm not sure where to start... I want it to be a comparison search engine for computer parts so say the user type in "RAM" it would display results from PC World, Ebuyer, etc. I was thinking of using cURL but how do I know where the search results are on each page. For example say I get a html page of results from PC World and store them in a variable how do I then know what to strip out to get the results I want? Would I just have to look at the source code? Also would I then have to work this out for each site I wanted to search from and have a different method of getting the results from search site? If anyone has done anything like this in the past and could give me some advice that would be great. Thanks I'm in the process of build a network and need to create a search that lets people search by both first and last names. I have tailored the code below to search for first names, but I don't know how to tailor it to search for both first and last names. Code: [Select] <?php //get data $button = $_GET['search']; $search = $_GET['search']; if (!$button) echo "You didn't submit a keyword."; else { if (strlen($search)<1) echo "Search term too short."; else { echo "You searched for $search<hr>"; require('connect.php'); //explode our search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { //contruct query $x++; if ($x==1) $construct .= "firstname LIKE '%$search_each%'"; else $construct .= " OR firstname LIKE '%$search_each%'"; } //echo out construct $construct = "SELECT * FROM users WHERE $construct"; $run = mysql_query($construct); $foundnum = mysql_num_rows($run); if($foundnum==0) echo "No results found!<p>"; else { echo "$foundnum results found!<p>"; while ($runrows = mysql_fetch_assoc($run)) { //get data $firstname = $runrows['firstname']; $lastname = $runrows['lastname']; echo " $firstname $lastname "; } } } } ?> This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=322620.0 hi frnds need a small favour...... i want to create a page with a simple text box and a submit button and as soon as i click the submit button it should get the data from the database matching to the text what i enterd in the text box and sholud display those data below the text box according to the number of keywords that are matching ..text that matches max keywords should display first...simply to say i need exactly the way google search engine homepage works... Mega thanks in advance pythagoras Hi, Im trying to do a search engine. However, im facing this errors.. Anyone can help.. Error : Notice: Undefined variable: searching in C:\wamp\www\i-document\s.php on line 17 Thankz in advance. Code: [Select] <h2>Search Form</h2> <form name="search" method="post" action="s.php"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="file_name">File Name</option> <Option VALUE="year">Year</option> <Option VALUE="downer">Owner</option> < </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <?php if ($searching =="yes"){ echo "<h3>Search Results</h3><p>"; if ($find == ""){ echo "<p>Please Enter a search term"; exit; } include "config.php"; $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $query = mysql_query("SELECT * FROM document WHERE upper($field) LIKE'%$find%'"); while($result = mysql_fetch_array($query)){ echo $result['file_ref']; echo " "; echo $result['file_name']; echo "<br>"; echo $result['owner']; echo "<br>"; echo "<br>"; } $matches=mysql_num_rows($query); if ($matches == 0){ echo "Sorry, we can not find an entry to match your query<br><br>"; } echo "<b>Searched For:</b> " .$find; } ?> Hello, I would like to build a php search engine against a mysql database. I am looking for a tutorial but haven't been able to find any good ones. Any ideas of where I can find one? I need one where I can search with several words and if it has the stemmer.class.inc and so on would be great also. thanks, df Good evening, I am a newbie when it comes to programming, and I am yet learning. With several help from this forum, and other websites, I am able to finish my very first PHP project. It worked fine, as well as the search engine. However, it is foreseen that the application will be utilizing huge amount of data which would require pagination when viewing. And so I found a tutorial from php freaks as well. However, after I integrated the codes from my web application, the search engine suddenly stopped working. It is still, when I leave the field blank, which would display all data. However, if I type down a search query on the field, it still displays all data. Can anyone help me on this? Here's my complete code: <link href="add_client.css" rel="stylesheet" type="text/css"> <?PHP include("dbconnection.php"); $query = "SELECT * FROM records"; if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' ORDER BY territory ASC" ; $result = mysql_query($query, $connection) or die(mysql_error()); } ?> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="199" align="center" valign="top"><a href="login.html"><img src="invent-asia.gif" alt="" width="152" height="58" border="0" /></a> <script type="text/javascript" src="menu.js"></script></td> <td width="176" align="right" valign="bottom"><a href="main.php"><img src="Home.jpg" width="104" height="20" border="0"/></a></td> <td width="130" align="right" valign="bottom"><img src="View.jpg" width="104" height="20" border="0"/></td> <td width="146" align="right" valign="bottom"><a href="add_client.php"><img src="Add.jpg" width="104" height="20" border="0"/></a></td> <td width="109" align="right" valign="bottom"> </td> </tr> </table></td> </tr> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="3" bgcolor="#1B1C78"><img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> </tr> </table></td> </tr> <tr> <td height="553" align="center" valign="top" bgcolor="#F3FAFE"><br /> <form name="form" action="view_client.php" method="post"> <br /> <table width="351" border="0"> <tr> <td width="137" align="left" valign="middle">SEARCH RECORD:</td> <td width="144" align="center" valign="middle"><input type="text" name="search" /></td> <td width="56" align="left" valign="middle"><input type="submit" name="btnSearch" value="Search" /></td> </tr> </table> <br /> <table border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="80" align="center" bgcolor="#E0E8F3">Territory</th> <th width="330" align="center" bgcolor="#E0E8F3">Employer</th> <th width="160" align="center" bgcolor="#E0E8F3">Name</th> <th width="80" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php $conn = mysql_connect('localhost','root','') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('invent-asia',$conn) or trigger_error("SQL", E_USER_ERROR); $sql = "SELECT COUNT(*) FROM records"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; $rowsperpage = 10; $totalpages = ceil($numrows / $rowsperpage); if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } if ($currentpage > $totalpages) { $currentpage = $totalpages; } if ($currentpage < 1) { $currentpage = 1; } $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT * FROM records LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); if($result) { for($i=0; $i<mysql_num_rows($result); $i++) { $id = trim(mysql_result($result, $i, "id")); $territory = trim(mysql_result($result, $i, "territory")); $employer = trim(mysql_result($result, $i, "employer")); $first_name = trim(mysql_result($result, $i, "first_name")); $last_name = trim(mysql_result($result, $i, "last_name")); echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$last_name.", ".$first_name."</td>"; echo "<td><a href='edit_client.php?id=".$id."'>edit</a> | <a href='delete_client.php?id=".$id."'>delete</a> </td>"; echo "</tr>"; } } $range = 3; if ($currentpage > 1) { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; $prevpage = $currentpage - 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { if (($x > 0) && ($x <= $totalpages)) { if ($x == $currentpage) { echo " [<b>$x</b>] "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } if ($currentpage != $totalpages) { $nextpage = $currentpage + 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } ?> </table> <p> <br /> </p> </form> <p> </p></td> </tr> <tr> <td height="38"><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white><img src="images/topspacerblue.gif" alt="" width="1" height="3" /> <a href="disclaimer.html"><font color="#FFFFFF">Legal Disclaimer</font></a> </td> <td width="560" align="center" bgcolor="#0076CC" class=white><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /> Copyright © 2006 - 2010 InventAsia Limited. All rights reserved. </td> </tr> </table></td> </tr> </table> Immediate response is very well appreciated. Thank you very much ^^ Can anyone please help me with my code. I would like to display the data from another column instead of the id in the url generated by the scirpt. Code: [Select] <?php include('/home/arts/public_html/shows/includes/config.db.php'); if ($link){ $rpp = 10; // results per page $adjacents = 4; $page = intval($_GET["page"]); if(!$page) $page = 1; $reload = $_SERVER['PHP_SELF']; $sql = "select * from craft_shows WHERE venue_state='MD' order by start_date "; $result = mysql_query($sql) or die(mysql_error()); // count total number of appropriate listings: $tcount = mysql_num_rows($result); $date = strftime("%b %d, %Y", strtotime($row['start_date'])); echo "<table class='table7' width='100%' cellpadding='5' cellspacing='1'>"; echo "<tr><td> </td><td>Date</td><td>City</td><td>Show Name</td><td>Attendance</td></tr>"; echo "<tr><td colspan='7'><hr></td></tr>"; // count number of pages: $tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number $date = strftime("%b %d, %Y", strtotime($row['start_date'])); $count = 0; $i = ($page-1)*$rpp; while(($count<$rpp) && ($i<$tcount)) { mysql_data_seek($result,$i); $row = mysql_fetch_array($result); $id = $row['id']; echo "<tr><td>"; echo "<a href=\"/show_submits/show_detail.php?id=$id\">Details</a>"; echo "</td><td>"; echo strftime('%b %d, %Y', strtotime($row['start_date'])); echo "</td><td>"; echo $row['venue_city']; echo "</td><td>"; echo $row['show_name']; echo "</td><td>"; echo $row['num_visitors']; echo "</td></tr>"; $i++; $count++; } echo "</table>"; echo "<br>"; // call pagination function: include("pagination1.php"); echo paginate_one($reload, $page, $tpages, $adjacents); } ?> I have a search bar that searches my databases for information. It works perfectly on my site,. I want to know how to make it modular so that other people can place my search box on their site and get results from my databse without having to give out all my site infomration. 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! Can someone help me with my code. Used a tutorial as aid but still struggling. Basically I have a table called student. I created a search engine so that if a user searches for either the sname,fname or sno of a student then that student would appear. Apart from some notices I got it working and displaying students when searching for only their sname. Now, I want to be able to make it possible to find a student by searching either sname,fname or sno and I'm getting errors. Can anyone have a look at my code: Code: [Select] <?php //get data $button = $_GET ['submit']; $search = $_GET ['search']; if (!$button) echo "You didn't submit a term."; else { if (strlen($search)<=0) echo "search term too short."; else { echo "You searched for <b>$search</b><hr size='1'>"; include 'includes/config.php'; include 'includes/functions.php'; connect(); //explode search term $search_exploded = explode(" ",$search); foreach($search_exploded as $search_each) { //construct query $x++; //Line 30 if ($x==1) $construct .= "sname,fname,sno LIKE '%$search_each%'"; //Line 32 else $construct .= "OR sname,fname,sno LIKE '%$search_each%'"; } $construct = "SELECT * FROM student WHERE $construct"; $run = mysql_query($construct); $foundnum = mysql_num_rows($run); //Line 44 if ($foundnum==0) echo "No results found."; else { echo"$foundnum results found!<p>"; while ($runrows = mysql_fetch_assoc($run)) { //get data $sname = $runrows['sname']; $fname = $runrows['title']; $sno = $runrows['sno']; echo " <b>$fname</b> $sname $sno"; } } } } ?> Errors:Notice: Undefined variable: x in C:\Program Files\EasyPHP-5.3.3\www\Project\search.php on line 30 Notice: Undefined variable: construct in C:\Program Files\EasyPHP-5.3.3\www\Project\search.php on line 32 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files\EasyPHP-5.3.3\www\Project\search.php on line 44 No results found. First time attempting this, so any tips on what I did wrong would be great. Thank you in advance. Php search engine for my site I have a Romanian based language site: http://www.firmelavedere.com with informations about business companies. I implemented a simple php search engine for my website on pages like this on the top right corner: http://www.firmelave...aj-Zalau-15.php I want to add a new radio box field to select language for displayed text. Is there a possibility to integrate Google Site Search with more languages? How can i do that? I need some code suggestions, to make this script run fast. Thanks all. Hi Everyone. Am about to create a search engine for my project using php and mysql. My question is that > Do i have to keep creating tables and entries in the database to contain all the topics to be searched for? Or is there another way to go about it? cos i dont think i can really enter all the search topics and their web address and also their keywords. Thank You. |