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.

No comments posted yet

Your Answer:

Login to answer
267 Like 54 Dislike
Previous forums Next forums
Other forums

How to display value in drop down list after form has been reloaded
Please bear with me as I am very new to php and html.

I have a form with several drop down me

PHP submit form script causing blank page
Im trying to submit a form using this script, however nothing shows up on the page, does anyone know

Applet JTextField Size Problem
Hello,

I recently started making an applet to calculate certain values for airplanes. However

Post PHP form to non-existing page
The company that I work for host their PHP code on IIS on a Windows server, no Apache, so no mod_rew

How to validate from 2 possible answers
Hi

I hope somebody can help me with what will probably be really simple, I'm pulling my hair

socket communication between c++/java and sending image
hi,

i have a class in c++ called win32_sockserver which creates socket to java. i am trying

generating all possible random letters
hi'

how can i randomize the letters a,b,c,d,e all possible ways, and i want to print the res

Feed Maker
Hi all.
First of all I must say I am not a php developer so I am afraid I don't know much about i

Count on multidimensional array
Hi, i got an array as below:

Array
(
=> Array
(

Variable passed to each() is not an array or object
Hi,

This is a email a friend type of form, and it isn't working anymore.

<?

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