Comparing MySql data and arrays.


Posted on 16th Feb 2014 07:03 pm by admin

I have a mysql table set up like this:
idsubjectbodyuseriddatetimetags1blog subjectblog body111|29|20099|30|AMblog,site news,tech
when displaying the data i want to be able to add "?id=blog&tags=blog,tech" to the url to search for multiple tags.

i'm pretty close with this:
Code: if (isset($_GET['tags'])) {
$tags = addslashes($_GET['tags']);
$srchinfo = "WHERE tags IN ('$tags')";
};
$result = mysql_query("SELECT * FROM blogs $srchinfo ORDER BY id DESC LIMIT $offset, $rowsPerPage");
but, when using the url, it will only show up posts that have one of the tags.

For example:
Post1: site news, blog
Post2: blog
Post3: blog,site news

"?id=blog&tags=blog" Only shows Post2
"?id=blog&tags=site news, blog" Only shows Post1

Anyone know what to do?
Thank you.

267 Like 54 Dislike
Previous php-forum Next php-forum
Other php-forum

PHP & Images [Resize, Crop, Save]
Hey! Well I have a little dilema, hoping I could find some guidance.

I have a CMS and on the

Cron Job and Output
I have php codes running under a cron job.
But everytime i output (echo) , it comes out as comple

Simple MySQL script is not working
Hey guys,

Just familiarizing myself with PHP and MySQL. I am following along in the O'Reilly

PHP mail() returns true but doesn't work
First off I apologize if this is a newbie question, and I generally don't like asking questions that

array_combine() trouble w/csv file
I have a problem with a piece of code I wrote to import some records from a csv file into mysql. I h

Parse Error Help
Hello, I got the parse error "Parse error: syntax error, unexpected ',' in register.php on line

why does my session end?
my connect.php starts the session just so you know
i can navigate arround my site fine except whe

include problem
I have my root folder as:
Code: $root = $_SERVER["SITE_HTMLROOT"]; // the server root<

how to export excel file in same server
My first post - php newbie, so appreciate your support.

I'm currently using headers to save w

pull content
I have an existing page, domain/adverts.php which has a good PR. I've just rebuilt my site and the n

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash