Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


 
 
LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 08-04-2009, 03:53 AM   #1 (permalink)
Junior Member
 
Join Date: 06-29-09
Posts: 19
iTrader: 0 / 0%
Latest Blog:
None

gilbertsavier in the red
Searching Database Using Like

Hi,
I 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
<a href="http://www.mioot.com">Live Chat Software</a> By miOOt
gilbertsavier is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selling Madhackerz.net Full Database - Admin Access+Forum Backup+Sql Database ReardoN Content 0 03-20-2009 11:25 PM
Searching for my URL gives a 'Did you mean' !? dudeman Google Forum 16 10-10-2008 02:43 PM
Searching towns ronnyd8719 Coding Forum 1 01-18-2008 01:20 AM
Searching for RSS directory Batch Web Directory Issues 3 09-04-2006 06:56 AM
Searching on directories Salman Web Directory Issues 3 11-20-2004 09:03 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 03:53 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.