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

Sorting JTable on more than just the values listed in the columns
I have a collection of objects that store (among other things) two integer values. I only want to di

listcube issue
Hi
I have a virtual cube ZREMOTE. I use Tcode "listcube" to retrieve contents. I use of the

JSON SORT WITH PHP
I have two products that I want to sort by say "Id:17, value: xxx" using php
The page w

Confusing Functions
So, I've been reading up on Functions and I like them! However, I need some help using variables in

update 2 columns by doing inner 2-column query
Hi,
is something like this possible?

update contract_all set col1,col2 =
(

how to insert value
I am having file bookissueadd.php..... in which i am having tag

<td height="21&q

puting for loop in 1 value
hi ,

how do i put this code in 1 value:
Code: <?php
for ($i=1; $i<=5; $i

Search in the PHP Files
have to search asterisk(*) in the php code of the php files .
In the html page one text box

Help with Contact Form
I have this Form on an html page and the associated code on page.php (below).
I keep getting the

Hyperlink in PHP to MySQL record
Hello,

I am having trouble as i am new to php. I have connected to the database and I have di

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