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.

Did you know?Explore Trending and Topic pages for more stories like this.
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

fwrite error
Hi All,
Does anyone know what is causing the error in this code?

Code: <?
$error

Filtering for a phrase using pregmatch
Here is my code which looks for addresses which start with ' src=" '

Code: [Select]preg_

upload image name with extension using php
hi frds..

<input id="file1" type="file" name="file[]" &a

problem when runing a funciton
I am trying to connect to database using a funciton in a functions.php

<?php
funct

Accept only alpha characters
I've got this bit of code ready for accepting a phrase:

Code: if (!eregi ("", $_POS

count only commas outside parenteses
I have a sql table containing
id - query - query name
the first page contains a drop down men

How do I send data using an html link
Hi

If I have
<a href="main_file.php">

How do I send data t

Escape Latin Characters
I need to escape latin characters in an xml doc. Example: "é" is escaped to "é". I thoug

Ajax not working on IE 6 for Windows CE
I've created a webpage which uses the classis Ajax in following format:view plaincopy to clipboardpr

Disable html within defined tags
I have a mysql database that allows users to enter content with html, but I also want to have a tag

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