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

Display search result
Hi!

I have a SQL database with information about albums and track (music).

This is wh

How to add an image/C++ OpenGL?
Hi,

I have been trying to look online for this and, so far, I haven't found anything usef

Is there a more efficient way to code this than what I have?
I have three associative arrays.

$combinedSettings
$userSettings
$defaultSettings

SQL Injection
In my attempts to protect my database from mySQL injection I have created another problem for myself

Do not allow posting of whitespace
Currently the script below works if the user does not type a name/message, but if i create a whitesp

Need help making a blockquote and line items conditional
I have some code I bought a few years ago that allows my clients to update content on their site usi

How to ask a regex question?
Hi, I thought I'd share some of my insight after seeing too many bad questions that either get ignor

Why does first ever HttpSendRequest take longer?
I promise this isn't as simple as it sounds. I'm wondering why the the first ever call to HttpSendRe

Exporting new records
Trying to figure out the best way to set this up.

People register my site.

Their prof

SAP Project Module
I have seen in the SAP Project Module,plan cost and budget are not equal and even difference is sign

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