Search Function That Highlight Result Instead Of Filtering It Out
I am trying to create a search function that will jump to the page containing the result and highlight it instead of filtering it out. To more clearly illustrate what I mean take a look at this link:
I would like to search for eg. "bruce wayne" (its record number 30) and just have that row highlighted. Anybody who could steer me in the right direction would be a massive help as I've spent the last 2 days trying to work this out with no joy.
View Complete Forum Thread with Replies
Related Forum Messages:
Filtering In Query Result With WHERE
I am trying to filter out records in a query using WHERE expressions. See example below. if ($league="All") {$leaguebool="1"} else {$leaguebool="League='$league'"}; $query = "SELECT League,HR FROM ranfranbattingsim WHERE ('$leaguebool') ORDER BY $sorder DESC LIMIT $limit"; My desire is to select all records if $league='All' and select only records where LEAGUE=$league if $league is anything other than 'All'. LEAGUE is one of the fields of the database. I hope that I explained that well enough. I am open to any solutions, and have considered that perhaps I should be using something other than the WHERE statement to filter the records.
View Replies !
Keyword Search And Highlight
I am creating one website with forum, In forum admin can add keywords like PHP,MYSQL.JAVA, C, C++... depends upon key word i have to search all posts and highllight the text and i add tool tip like this I am trying for str_replace ,preg_replace but some of key words are like this( MAN,WOMAN,ROM ANACE) here the text MAN is highligting if the text has WOMAN it is taking inner string ....
View Replies !
How To Highlight Search Terms
Commonly done, eg. you enter a word in a search engine and when a hit-page comes up the search word(s) are highlighted. I'm doing a fulltext search that works well but I've tried a few "packaged scripts" and haven't got one to work yet. I'm looking for straightforward understandable way to do this on my MYSQL/PHP pages.
View Replies !
Highlight Search Terms In Results Pages
I am trying to find a script or code that will highlight search terms output from my MySql db. I have posted a portion of my pagination page below. The pagination script provides ten records at a time. For example, I need code, a script, or a funtion to grab the search term coming from the user and generate highlighted keywords when the keywords are entered by the user in the html forms search box. In the code below, I have inserted sample code so you can see how the display appears. In actual practice, the $Source, $Topic, $Subtopic, and $References values come from the while(list($Source, $Topic,$Subtopic,$References)= mysql_fetch_row($result2)) { code line. Code:
View Replies !
Highlight Found Boolean Search Terms
I have a boolean search feature for my site. On the standard non-boolean search features I have highlighting of the found terms. I want to be able to highlight found terms of a boolean search. Is there a way to highlight found search terms for a boolean result set? OR Is there a way to explode the result string of the Select statement and pick out the words used by the embedded MySql boolean search engine? Code:
View Replies !
Filtering Out Keywords In A Search!
I have about 1100 movie titles in a database. I am trying to do a simple search engine and have seperated each keyword using the following code: $q = $_GET['q']; if ($q) { $q = strtolower($q); $k = split(" ", $q); $num_keywords = count($k); for ($i=0; $i<$num_keywords; $i++) { if ($i) { $search_string .= "OR moviename LIKE '%" . $k[$i] . "%' "; } else { $search_string .= "moviename LIKE '%" . $k[$i] . "%' "; } } end for $and .= "WHERE ($search_string) "; } //end if $querycount = "SELECT * FROM titles $and"; rest of code... This works ok, but if I type something in like 'The Killer' it fetches everything with the word 'the' as well. I have put the words into an array that I want to filter out. $skipwords = array("the", "of", "and"); etc Can I use that to filter out the words? I`ve been playing around with the in_array() function, but can`t seem to get it to work like I want it to.
View Replies !
Search Query By Filtering
i have a a table with the following fields id, company_name, telephone_number, mobile_number, name and date. i also have a form with the following 4 fields company_name, telephone_number, name and date, is there anyway that i could search the database and display the results found depending on the values entered on the form, however all the form fields do not have to be filled in. so it could just be a search where the name is entered or the date, or both. Code:
View Replies !
Filtering Words In Search
I have a search script that searches my database using mysql's "LIKE"... I want to filter out words such as "a, the, is, as, I" I can't think of them all off the top of my head and was wondering if anyone had a list laying around somewhere?
View Replies !
Code Highlight Function
if anyone out there has a good function to highlight code. PHP's highlight_string function chokes whenever the string contains certain characters. Most of the functions I've found through Googling work with files. I'm looking for something that can handle a string.
View Replies !
Search Field And Search Result Troubles
I am trying to create a search feature for a site. A user will enter a keyword, click submit and a query will execute and compare the users input to several fields in the database and the results will be displayed on the screen. If it's not too difficult I would also like the search to find words that are similar to what typed in by the user. For example, if the user makes a typo, results similar to what they typed in will be displayed. I am using PHP, MySQL and PEAR. Code:
View Replies !
Search Result Help
I am trying to do the following with my search script that looks for records in a mysql table. The following is an example of what I am trying to do. Text being searched: -- The brown fox jumped over the green fence then jumped into the web monitor. It was hurt so it jumped backwards and fell on its! -- The word we're searching for "web". The results should look like -- ...then jumped into the *web* monitor. It was... -- Are there any functions out there that will do this? Or what would it take to make one?
View Replies !
Counting Search Result
I want to develop the result next/prev/1-10/11-20 etc thing.Say we have N records. We limit it to display M records at a time. So I have a question which is better, performance wise: Code:
View Replies !
Get Percentage Of Search Result
I'm not sure if this is php or mysql, but I'm trying to find a function which gets the percentage match of a mysql query. I've seen it before, but can't remember it now.. I also can't remember whether it was a php function or mysql. I'm well aware that I can figure out percentages with a bit of multiplying, dividing etc, but I'm sure there's a simple bit of code to do it for me.
View Replies !
Find A Search Result
I have paginated page sets. and I have a search routine in a different html page. it works if the search result goes to a simple page with ten results (the limit count). Using a href # will jump to my correct result. while also displaying surrounding results. But if I have six paginated pages of ten results each and the requested result is like row 43, how do I tell the script to "go" to that page [in other words how to select the right rows via offset 'cos I dont know the offset value] I guess I need a way to calculate the offset value of the row within the result (based on any ORDER BY criteria). Does this just mean I do the query twice, once to get the row position, next to do the actual select query and pagination? Or is there a better way : here's some mock SQL of what I hope exists: SELECT rowoffset(*) from stuff WHERE row_id=search_id ORDER BY $ordervar
View Replies !
Search Result To Next Page
how do I do those search results with display limit? Like displaying 20 results per page and user have to click NEXT to view next 20 results. And of course a BACK link too.
View Replies !
Search Form Result
I have a search form the results from which is displayed on a page. My problem is the search displays a lot of duplicate customers as well. Code:
View Replies !
Search Engine Result Parsing
Does anybody know where can I get a get tutorial on regular expression. I search a lot but I am getting only the manuel most of the time. I am searching for perl compatible regular expression in PHP. I want to use preg_match_all to parse search engine results.
View Replies !
Search Page Result Links
I have a search function pulling data from a MySQL db which works nicely - other than the fact that I can't get the URL to link correctly when the linked document is located in the home directory. All other docs are located below the home directory by group/project/category. When I try to use an 'if' statement for one of the query parameters, I either lose the link, get a link that has the doc that is in the home directory with the full path (that doesn't really exist as folders), or get an undefined index error. Here is my current code - I have edited it several times over that past couple of hours, so I have reached the point of not being able to tell what is correct, and what isn't. I have used projCode, groupCode, projID, groupID parameters and still can't find the magic solution. I would really appreciate another set of eyes. ---snip--- mysql_select_db($database_website, $website); $query_search = "SELECT Distinct docURL, docTitle, docDesc, docs.projID, groupCode, projCode, catName FROM docs JOIN subcat on subcat.subcatID=docs.subcatID JOIN cat on cat.catID = subcat.catID JOIN groups on groups.groupID=proj.groupID JOIN proj on proj.projID=docs.projID WHERE proj.projID=docs.projID AND docURL LIKE '%$keyword%' OR docTitle LIKE '%$keyword%' OR docDesc LIKE '%$keyword%'"; $search = mysql_query($query_search, $website) or die(mysql_error()); $row_search = mysql_fetch_assoc($search); $totalRows_search = mysql_num_rows($search); $proj = $row_search['projCode']; ?> <?php if ($totalRows_search < 1) { echo "No internal documents matched your request."; } else {?> <p><table width=95%> <tr><td colspan="3"><font size="+1">Internal Documents:</font></td> </tr> <tr> <td><strongLink </strong></td> <td<strong>Description</strong></td> <td<strong>Project </strong></td> </tr> <?php do { ?> <tr> <td> <a href="<?php if ($row_search['docs.projID'] == 1) { echo $row_search['catName']."/".$row_search['docURL']; } else { echo $row_search['groupCode']."/".$row_search['projCode']."/".$row_search['catName']."/".$row_search['docURL']; ?>"><?php echo $row_search['docTitle'];......
View Replies !
Mysql Search Close Result
I've to find in a table the "closer" result given some text. Here is a little example: given the text "Batman socks" I've to find the best matching result in choices like: -"mickey socks" -"robin socks" -"batman black socks" ->this should be found -"batman wallet" -"batman" or given the text "leather shoes" I've to find the best matching result in choices like: -"socks" -"shoes" ->this should be found -"pants" -"shirts" -"leather wallet"
View Replies !
Turn A Search Result Into A Link?
I used a search tutorial to create my search function, which i have managed to link to my table and carry out correct searches. How do I edit the script to now turn the title of my search into a link to the product? all my products are linked like this: categories.php?c=0&p=70 ie 'p=70' being the product id. The code that dispalys the data looks like. Code:
View Replies !
Adding Pagnition To Search Result
I am using a very simple search script. But the script shows all the results in one page... What I want to do is that when there are >10 results then it will divide them into pages. For example search comes up with 50 rsults then it shows 10 in 1st page, 10 in 2nd and so on... At the bottom of page there should be hyperlinked pagnition if result shows more than 1 page > 1,2,3,4,5... Also there should be option for next and previous page... Which would look like this > 1,2,3,4,5 [Next] [Previous] . The page which is current should not be hyperlinks and if there is no previous or next page then it [previous] & [Next] should not be shown. I also want to specify different front size to current page pegnition e.g. 1,2,3,4,5 [Next] [Previous] Code:
View Replies !
Distribute Search Result In Pages - Pagination
How can I distribute a search result in different pages? For example I have 10 search results (searching for database) and I would like to get 7 results per page. So there will be 2 pages, first 7 results in first page and rest 3 results in second pages. I am just simply querying from the database. What will be the best and easy sollution?
View Replies !
Crawling Google Search Result Pages
I want to make a crawler in php that will crawl google search results for given keywords. Procedure will be something like this: 1. There will be a list of thousands keywords in file with csv or other format. 2. Crawler will crawl google.co.in for each keywords in the file. 3. Top 10 results title, description and the url will be collected and stored in MySQL database. 4. Now crawler will crawl for next keyword after some delay and loop will go on unless reach to daily limit of keywords to crawl. Then next day it will start again. I need some suggestion on: 1. How to crawl pages without using any addons. (Because I am going to run this from an free server not my machine so I will only have php, mysql and general features. ) 2. What kind of parsing I should use to extract title, description and urls from HTML code. 3. What should be the delay and daily crawl limit. ( I don't want to get banned by google for automatic query. )
View Replies !
Create A Search Result On A File Directory
I am working on a project where I need to take a variable from a form, then match that variable against a directory list and return a modified list of files available that are clickable. I have created the form - (easy part) and I have found coding that pulls the directory list. I am having trouble finding information on how to take that directory list a sort the results based only on the keyword that was typed in.
View Replies !
Dividing Search Query Result Into Subcategories
ok having a bit of a problem with modifying my search to include subcategories display. Curretly my DB has the following fields Title¦Price¦School the thing is that i want the search results to show results accouring to the school field. Example Physics for Engineers- Senneca College (8) Physics for Engineers- Toronto University (2) Physics for Engineers-Alberta college (1) and so on.... i though of creating seperate tables for each school, but that would be a ton of tables for each school...to create modify and maintain.
View Replies !
How Can I Count The Rows In A Search Query Result?
I'm building a PHP/MySQL search engine and I want to count the rows returned in the search, in addition to the search results themselves. So far, I have this code within the script, and I need the variable $row_count to be the number of rows returned in the main search query: Code:
View Replies !
Search Function - Search In MySql Databases., How To?
How do I set up a page where the visitors can search through a mysql database? It's linxcafe.net Im talking about. I want the visitors to be able to seach among all my links (both categories and links) so they find what they are looking for easier. I have searched on google after tutorials on this but I have only found complicated ones.
View Replies !
Ranking MySQL Result By Number Of Matching Fields Against Search Words
i am adding a search capability in my webpage, i need to search for words selected by users using buttons in a form. i use this cause they will be searching for a word per field on the table. my query will be somethign like this: SELECT t1.f1, t1.f2, t1.f3, t1.f4 from t1 where t1.f1="red" ¦¦ t1.f2="manual" ¦¦ t1.f3="4WD" ¦¦ t1.f4"new"; the query work fine but the results are not sorted by number of matches, example if car1 is red, manual, 4WD, and new it should be the first one cause its "score" in matches is 4, then car2 if "score" is 3 will come next in the list, those with only one matching field will be the last ones, of course if no matching fields the car will not be in the results. Code:
View Replies !
How To Add Function Result To Array?
The way I'd like to set up a particular set of functions is to have them either return TRUE or, for example: $errors[type] = "Sorry, the file type is not allowed. Allowed types are ".print_array_inline($acceptedTypes).". "; Then later, I have a foreach loop that echos each array element. However, when I echo each array element is doesn't output the whatever the print_array_inline function does. Any suggestions?
View Replies !
Search Function To Search For A Certain Keywords
I'm using a search function to search for a certain keywords and what I need it's to remove any spaces and any of theses words(and|or|not). Then after inserting these into the database. These is the code: $new_keyword=preg_split('( and | or | not )', $keywords, -1 , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); print_r($new_keyword); foreach($new_keyword as $k=>$v){ $s1="INSERT INTO Searches (Search, DateAdded) VALUES("".$v."", NOW())"; db_q($s1); } It remove and|or|not but not the spaces.
View Replies !
Query Result Navigator Function
I've just updated this, and I thought I'd also say that not only can this provide a page navigation for MySQL or other database results, but can be used to navigate other lists.. such as a file list. PHP Code:
View Replies !
Adding Result Row To Mail Function
I have an email script that will pull the addreses from my club membership database. That part works fine. the problem I am having is being able to include row results inside of the actual email message. My message variable is something like this: Code:
View Replies !
Saving Result Of Function Without Being Echoed
I am trying to save the function "rand(1, 1000000)" in a variable but when I am for example trying: $randomnumber = rand(1, 1000000); it is executing it right ahead while when i try $randomnumber = "rand(1, 1000000)"; or $randomnumber = 'rand(1, 1000000)' It is saving rand(1, 1000000) as variable. But what I need is a variable saving the result of rand(1, 1000000) so the number does not change either. Any ideas how I would do this?
View Replies !
Storing The Result Of Javascript Function
how do I store the result of a javascript function into a PHP variable? I have a div that is hidden or shown based on whether or not a checkbox is clicked. Initially the div needs to be hidden. So how do i make sure that it will be hidden in all browsers when the page loads. The code for hiding and unhiding it works in the different browsers i have tried, but not initially being hidden. attached is what I currently have.
View Replies !
MySQL Result To Real Array In Function
I'd like to create a function which input is the result of a mySQL query. The output should be exactly the same, only not a mySQL result array, but a 'real' array. So it should also get the fieldnames returned by mySQL and use those as keys. I can't get things to work properly: it should return a multidimensional array, like $result_array[1] = array( [field1] => field1 value, [field2] => field2 value, etc. ) somehow my result is (with code below) $result_array[1] = array( [0] => field1 value, [field1] => field1 value, [1] => field2 value, [field2] => field2 value, etc. ) +++++ code ++++++ $get_res= mysql_query(QUERY); if( $res = mysql_fetch_array( $get_res ) ) { do{ $result[] = $res; }while( $res = mysql_fetch_array( $get_res ) ); }; foreach( $result as $key => $value ){ print_r($value); };
View Replies !
Assign MySQL Function Result To PHP Variable
I know to use: mysql_fetch_row($result) to convert a row from a SQL query result set into an array for use with PHP. but in the case of SQL queries that return one value, such as calls to MySQL functions, is there another PHP mysql api function I should use. For example, right now I use a "workaround" technique from PHPBuilder: $result=mysql_query("SELECT COUNT(*) FROM tablename"); list($numrows)=mysql_fetch_row($result); Rather than using this "workaround" code is there a way to simply assign the result of the MySQL function query to a variable. $result=mysql_query("SELECT COUNT(*) FROM tablename"); $numrows=mysteryfunction($result);
View Replies !
Chmode With Mkidir Function, The Result Isn't As Expected
I've tried to create a directory with the php function mkdir(). I've used a "0777" mode , so that owner,group and other can read,write and exectue files in this directory. There's no problem creating the directory, but after it has been created, its mode is "0755". Where did I commit a mistake ?
View Replies !
Using The Function Prevents Accessing The Result Of The Match.
I don't know if this is possible, but it should be. However, it doesn't seem to be working for me. how I can get it to work: I use :||: for my delimiter for str_replace, etc. When replying, the new PM is appended in front of the existing chain of replies, thus the same table entry is used and updated each time. Problem is in storing the sent date, and providing time zone and format adjustments: $string='This is the message that was sent on :|1161850848|:' $newString=preg_replace('/([0-9]*)/',format_time(adjust_time('${1}')),$string); // the result of this is as if ${1} = 0 $newString=preg_replace('/([0-9]*)/','${1}',$string); // returns 'This is the message that was sent on 1161850848' It seems that using the function prevents accessing the result of the match.
View Replies !
Function To Test If Mysql_fetch_array($result) Pointing Last Record?
I try to perform multiple insert statment, but the problem is in the below codes, the last sql concatenation ends with ",". I wonder if there is any php function to test if the $result set contains the last record. ------------------ //Get topic id of vote_topic from last insert record $sql_topic_id = "SELECT topic_id FROM vote_topic ORDER BY topic_id DESC LIMIT 1"; $result = mysql_query($sql_topic_id,$conn); $row = mysql_fetch_array($result); //Get all student info from stuinfo $sql_strn = "SELECT strn from stuinfo"; $result1 = mysql_query($sql_strn,$conn); //Dump all student strn into vote_status. //Multiple insert statement? How? $sql2 = "INSERT INTO vote_status (strn,topic_id) VALUES "; while ($row1 = mysql_fetch_array($result1)){ $sql2 .= "VALUES ('".$row1[strn]."','".$row[topic_id]."'),";} mysql_query($sql2,$conn); ---------------------
View Replies !
Refreshing Cache Through Php Header Function Yields No Result?
I am building a website for a client. He wants a login page with a "Your account" page for his clients. I am using a combination of javascript and php. Upon succesful login $_SESSION variables are set to 1. example: $_SESSION['logged']= 1; If the client logs out due to idle time or pressing 'logout' these values are set to zero. example: $_SESSION['logged']= 0; Upon loading of "your account" and any of its sub-pages, that page checks $_SESSION['logged']. If the value is zero it redirects automatically back to the login page. Providing oppertunity to log in again if you wish. The checking of $_SESSION['logged'] is supposed to redirect even if the client has logged out, but has pressed "back" on the browser to try and see a login page. The page does not do this. Pressing "back" reveals the page. Interacting with the page or pressing "refresh" THEN causes it to redirect. I need the page to auto-redirect, not show. I am aware that it is the page being cached and keeping those values until you interact with it. I have fully tested the header function in php. Using 'must-revalidate' & 'no-cache' and other version! (most info from php.net). I get no errors when testing the pages, so my code is correctly spelled! But there is simply no reaction by the page, it just does what it does, which is not what it is supposed to do? I ask for experience! Is there a specific way of doing the header functions? Perhaps it must be placed in a specific place in the page? And how can i check that the page is actually using the functions and not just moving over them with no action taken?
View Replies !
Warning: Mysql_result() [function.mysql-result]: Unable To Jump To Row 0
i want to grab the value of a sql entry. but the thing is, sometimes this value is <NULL>. i thought, no biggy, i'll just have an if statement: if (is_numeric(mysql_result($query, 0))) { //do something } else { //do something else using mysql_result($category_id_query, 0); } however, this doe not work. i get this error: Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 is there a way to check to see if mysql_result() is <NULL> without throwing an error.
View Replies !
Highlight Row
i'm having trouble in highlighting a row if a specific value is present in the results. for example: if i had the row of results with the headings id, name, address and the ids displayed were 1,2,1 how do i highlight the whole row of results were the id is equal to 1.
View Replies !
Search-function
I'm trying to make a small search-function for a musicsite I'm currently working on. Since I'm pretty much a newbie I'm just trying stuff out and here's what I've done and what I need help for. Currently the script splits the input and does a search on each word and then spits out the results with the correct links of course. But at this stage, if you ie. search for The Jackson, you'll end up with all the results matching 'The' and 'Jacksons'. Since this particular group actually exists, how do I narrow it down to just return The Jacksons? The name is registered like Jacksons, The btw.
View Replies !
Own Search Function
I have many urls. For example: /urls/yeah.html /urls/yeah2.html /urls/yeah3.html /urls/yeah4.html I have also a main page that has a search box where you can type for example "welcome" and then hit Search button. Then it should display ALL sentences that contains word "welcome" in those urls above. How would you do that? I know how to fetch info from urls with fsockopen and then use preg_match to see if there is text but can you write me a regular expression? "hello and welcome to my world! It's beautiful day today!!" If I search now for welcome it should return: "hello and welcome to my world!". But if I search for a word "it", it will return me: "It's beautiful day today!!". so the sentences that has the word.
View Replies !
Search Function
I have a search function on a site of mine. At the moment, the content is delivered using this: <?php echo $row_Recordset1['content']; ?> The search function goes through the table and displays the titles of the pages that contain the term. What I'd like to do is set it up so that when the visitor clicks on a title, it sends the search term as well, looks for it in $row_Recordset1['content']; and puts <strong> before and </strong> after. Does that make sense? Also, I've just noticed something not right. The CMS takes a text box and writes the HTML into the table. So, if I do a search on </li> for example, then it brings back results. I can't even begin to imagine a way round this. In most cases this is unlikely to be a problem but I'd like to think there might be a way round it.
View Replies !
|