Hi all,
I have been searching for some clues as to how to show a substring from a
database search.
$pagetitle = "Page Title";
$pagetext = "This is <b>a typical</b> string that would be stored<br>in the
database.";
Search for "that"
results would look like
1. Page Title
...string that would...
2. Another page
...computers that can...
3. Further Page
...languages that are...
At the moment the search results just show the page title. The idea is that
in the set of results I can show the user the context of each result, a bit
like a search engine does. Ideall I would like up to 10 words either side
of the search keyword.
BTW php+ mysql
Nel. 3 2273
Nel wrote: Hi all,
I have been searching for some clues as to how to show a substring from a database search.
$pagetitle = "Page Title"; $pagetext = "This is <b>a typical</b> string that would be stored<br>in the database.";
Search for "that"
results would look like
1. Page Title ...string that would... 2. Another page ...computers that can... 3. Further Page ...languages that are...
At the moment the search results just show the page title. The idea is that in the set of results I can show the user the context of each result, a bit like a search engine does. Ideall I would like up to 10 words either side of the search keyword.
BTW php+ mysql
Nel.
Hi Nel,
use LIKE
SELECT pagetext FROM tblpagetext WHERE (pagetext LIKE '%that%');
Because we don't know how your database is designed it is impossible to say
how the pagetitle should be retrieved.
I expect you reference a foreign key in tblpagetext on the PK in
tblpagetitle??
Anyway, if you have the pagetext in it is easy to get some words around it.
use explode on space and find the location of the first 'that' and get 5
before and 5 after (if possible).
go to www.php.net and browse a little for explode and count and the like.
I am quite sure somebody handy with regexpressions codes this in 1 line. :-)
Good luck!
Regards,
Erwin Moller
"Erwin Moller"
<si************ *************** *************** @spamyourself.c om> wrote in
message news:41******** *************** @news.xs4all.nl ... Nel wrote:
Hi all,
I have been searching for some clues as to how to show a substring from
a database search.
$pagetitle = "Page Title"; $pagetext = "This is <b>a typical</b> string that would be stored<br>in the database.";
Search for "that"
results would look like
1. Page Title ...string that would... 2. Another page ...computers that can... 3. Further Page ...languages that are...
At the moment the search results just show the page title. The idea is that in the set of results I can show the user the context of each
result, a bit like a search engine does. Ideall I would like up to 10 words either
side of the search keyword.
BTW php+ mysql
Nel.
Hi Nel,
use LIKE
SELECT pagetext FROM tblpagetext WHERE (pagetext LIKE '%that%');
Because we don't know how your database is designed it is impossible to
say how the pagetitle should be retrieved. I expect you reference a foreign key in tblpagetext on the PK in tblpagetitle??
Anyway, if you have the pagetext in it is easy to get some words around
it. use explode on space and find the location of the first 'that' and get 5 before and 5 after (if possible). go to www.php.net and browse a little for explode and count and the like. I am quite sure somebody handy with regexpressions codes this in 1 line.
:-) Good luck!
Regards, Erwin Moller
Thanks Erwin. I have no problem with the SQL side, just not expereinced in
arrays too much.
If I explode(" ",$pagetext ) this will only give me full words. the search
string could be part of a word.
Is there a regex that could just take (up to 40 chars)(searchte rm)(up to 40
chars)?
Thanks.
Nel.
"Nel" <ne***@ne14.co. NOSPAMuk> wrote in message
news:41******** *************** @ptn-nntp-reader01.plus.n et... "Erwin Moller" <si************ *************** *************** @spamyourself.c om> wrote in message news:41******** *************** @news.xs4all.nl ... Nel wrote:
Hi all,
I have been searching for some clues as to how to show a substring
from a database search.
$pagetitle = "Page Title"; $pagetext = "This is <b>a typical</b> string that would be
stored<br>in the database.";
Search for "that"
results would look like
1. Page Title ...string that would... 2. Another page ...computers that can... 3. Further Page ...languages that are...
At the moment the search results just show the page title. The idea
is that in the set of results I can show the user the context of each result, a bit like a search engine does. Ideall I would like up to 10 words either side of the search keyword.
BTW php+ mysql
Nel.
Hi Nel,
use LIKE
SELECT pagetext FROM tblpagetext WHERE (pagetext LIKE '%that%');
Because we don't know how your database is designed it is impossible to
say how the pagetitle should be retrieved. I expect you reference a foreign key in tblpagetext on the PK in tblpagetitle??
Anyway, if you have the pagetext in it is easy to get some words around it. use explode on space and find the location of the first 'that' and get 5 before and 5 after (if possible). go to www.php.net and browse a little for explode and count and the
like. I am quite sure somebody handy with regexpressions codes this in 1 line. :-) Good luck!
Regards, Erwin Moller
Thanks Erwin. I have no problem with the SQL side, just not expereinced
in arrays too much.
If I explode(" ",$pagetext ) this will only give me full words. the search string could be part of a word.
Is there a regex that could just take (up to 40 chars)(searchte rm)(up to
40 chars)?
Thanks.
Nel.
I have been messing with
..{0,30}[:alnum: ]($search)[:alnum: ].{0,40}
but this only gives words surrounded by spaces, not part of word or word
followed by , or .
HELP!!!!!!!
Nel. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: cassandra.flowers |
last post by:
Hi,
I have another string handling question for the group, since you have all
been so helpful in the past. Thank you.
Basically, I want to do something really simple:
Search a main string for a substring, then count how many times the
|
by: Anand Pillai |
last post by:
To search a word in a group of words, say a paragraph or a web page,
would a string search or a regexp search be faster?
The string search would of course be,
if str.find(substr) != -1:
domything()
And the regexp search assuming no case restriction would be,
|
by: todd |
last post by:
here is a search tool SP I wrote.
How many times have you wanted to search all your Stored procs or views (in
a
database) for a keyword but couldn't!?
Well now you can! THis can makes life a lot easier for developers.
Would you email me and let me know which part of the world my code is
running in?
|
by: gwtc |
last post by:
Here is a google search site bookmarklet. This lets you search a
certain website using google. What I want is the same thing, but to
search a certain geocities site. When you use the current
bookmarklet, the search takes you to site:www.geocities.com instead of
the specific site you want to search. Can someone modify this for me,
to search specific geocities sites?
Thanks for your help and btw I'm using Mozilla Suite and Firefox.
...
|
by: balakrishnan.dinesh |
last post by:
Hi frnds,
Im having a problem in searching out a particular substring in a
string.
Here the code:
---------------------
<html>
<script>
var tmpString=" ";
| |
by: coolami4u |
last post by:
I need a program that simulates the search-and-replace operation in a text editor. The program is to have only three function calls in main. The first function prompts the user to type a string of fewer than 80 characters. It then prompts the user to type the search-substring of 10 or fewer characters. Finally, it prompts the user to type the replace-substring of 10 or fewer characters.
The second function call is the search-and-replace...
|
by: Richard S |
last post by:
CODE: ASP.NET with C#
DATABASE: ACCES
alright, im having a problem, probably a small thing, but i cant figure out, nor find it in any other post, or on the internet realy (probably cuz i wouldnt know what to search for), but heres the problem:
I am making a search function for my website, i want this to be possible:
- search for 1 keyword (the problem guy)
- search for multiple keywords
things that alreaddy work (so no problem with...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |