How to get more than one bank category in the same table

0

I'm developing a system for watching movies online and wanted to know how do I make movies that are in 2 categories listed in both categories. I'm getting to list only at first ... could anyone help?

I have the movie table on my system and there is a field called varchar(100) category.

code:

<?php
require "conexao.php";
$cat = $_GET['cat'];
          $sql = "SELECT * FROM filme WHERE categoria = '$categoria' ORDER BY nome LIMIT 10";
            $qr = mysql_query($sql) or die(mysql_error());
            while($aux = mysql_fetch_array($qr)){
                $nome = $aux['nome'];
                $img = $aux['img'];
                $cate = $aux['categoria'];
                $sinopse = $aux['sinopse'];
                $cod = $aux['id'];
                print"
                        <div class=\"categoria\">
                            <ul class=\"col-md-3\">
                                <li><a id=\"popover\" data-trigger=\"hover\" data-toggle=\"popover\" title=\"$nome\" data-content=\"$sinopse\" href=\"watch.php?cod=$cod\"><img src=\"images/capa/$img\" title=\"$nome\" ></a></li>
                                <span class=\"resto2\">Hdtv</span>
                                <strong class=\"text text-center\">$nome</strong>
                            </ul>
                        </div>";
            }
?>

Here is the code I want to get the category and in my index I have the href

<a href="algumacoisa.php?cat=acao">

and has more categories:

<a href="algumacoisa.php?cat=aventura">

What I wanted to know and how do I list a 2 category movie as in the example filem has the category of action and adventure. How do I make it appear on the 2 pages of Action and Adventure?

    
asked by anonymous 26.08.2015 / 04:13

2 answers

0

Good Night!

And if you try to use the SELECT LIKE

$sql = "SELECT * FROM filme WHERE categoria IS NOT NULL AND categoria like '%$cat%' ORDER BY nome LIMIT 10";

"I'm new here, I hope to learn more here too"

    
26.08.2015 / 05:01
0

You can create an array with categories and make a select of them, for example:

SELECT * FROM filme WHERE categoria = IN ('acao','aventura')  ORDER BY nome LIMIT 10

Since I do not know how you are selecting more than one category, let's say you change your href to something like:

<a href="algumacoisa.php?cat=acao+aventura">

Then you just have to explode in php to return only the array that you want "acao","aventura" or you can do some solution in javascript, for example the one I made in jquery .

alert($("a").attr('href').slice(20).split("+"));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script><ahref="algumacoisa.php?cat=acao+aventura">Link</a>

You can already have a notion.

    
26.08.2015 / 05:06