Go Back   Free website templates > Web Template Help > PHP and MySQL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Join now to download all the free website templates or post on the forum. If you have never been on a forum before read the FAQ. It's quick, easy and free to join!
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-04-2009, 12:52 PM
Junior Member
 
Join Date: Jun 2009
Posts: 25
gilbertsavier is on a distinguished road
Default Searching Database Using Like

Hi,
am trying to query my database for specific words in variables.

I have one database titled pranks with a column called prankentry and tags

Another database holds an ID number and an entrytext column.

I pass the ID number through the URL to /pranks/index.php?id=26. On index.php i am running a query to try and find similar items in the pranksentry row.

Here's my code:
$id = $_GET['id']; //GET ID
$query = "SELECT entrytext FROM hmr WHERE id=$id"; //GET POST
$result = mysql_query($query);

while($row = mysql_fetch_array($result))
{
$text = $row['entrytext']; //CHANGE VARIABLE

}
$sql = "SELECT * FROM pranks WHERE pranksentry LIKE '%$text%' ORDER BY id DESC"; //GET PRANKS SIMILAR to TEXT
$result5 = mysql_query($sql);

while($row = mysql_fetch_array($result5))
{
$prank = $row['prankentry'];
echo $prank; //OUTPUT Prank
}
It's very strange. By setting $text = 'test' and putting a prank into my that table with the text, 'testing to do this testing to do that'. The code above displays that line.
However, if i set $text = "he talks too much, and never shuts up." and have a prank in my database with the text, 'shuts', it does not show the results i would like.

Thanks & regards
Lokananth

Last edited by CovertPea; 08-04-2009 at 01:26 PM.
Reply With Quote
  #2 (permalink)  
Old 08-07-2009, 11:07 AM
Junior Member
 
Join Date: Aug 2009
Posts: 3
Carmi Stanko is on a distinguished road
Default

Search engine create their database by following links and indexing the content they find. They can not specifically search someone elses database unless there exists a link to the data. So the search engines ability to see the content is based on finding a link to the data. A quick rule of thumb is that when using a web browser, any page you can find by clicking links can be found by a search engine. Any page that can only be found by entering information via a keyboard is unlikely to be indexed.

Last edited by CovertPea; 08-07-2009 at 11:47 AM.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:53 AM.



mouseover mouseover mouseover