Okay, So short and sweet. I have a field in my database that is LONGTEXT. This field usually has around 2,000 lines of text in each of these.
What I need it to do, is go through this LONGTEXT field and take out the line that has what is inputted to it. (Sorry, I am horrible at explaining things)
For example, I originally used .txt files, but decided that MySQL was a much easier way to go as I do have a little bit of experience in it. I have this code.
function searchcode($search)
{
$count = '0';
$lines = file('file.txt');
foreach($lines as $line)
{
if(strpos($line, $search) !== false)
{
echo "<tr><td>" . $line . "</td></tr>";
$count++;
}
}
echo "<tr><td style='border-top: 2px solid #000;'>$search was taken a total of $count times.</td></tr>";
}
CODE FOR SEARCHING FOR: searchcode("Camera");
This will look though the .txt file I want it to and display the lines based on what $search is. I want exactly this, but with MySQL.
In this example I was searching for a camera. And it would look through the .txt file and boom, every line with the word camera in it would display. (And the count of it obviously.)
LETS MAKE THIS CRYSTAL CLEAR: I'm looking for something to search the longtext field. Then display results based on a certain word.
I already know about the LIKE syntax, but I have no actual idea on how to use it!
EXAMPLE OF WHAT I WANT
[-Database-]
ID---------Date---------Information
1 ---------3-4-2012----camera has been removed. Jacket has been removed. camera has been added.
[-MySQL Page-]
MySQL Code Here
[-Webpage-]
Camera has been removed.
Camera has been added.