B
B
Bobur Bakhritdinov2015-12-13 15:33:48
PHP
Bobur Bakhritdinov, 2015-12-13 15:33:48

Sql query "Related materials"?

Task:
There are 2 tables:
1) torrents, (there are columns like "id, name, image, genre)
2) tags (id,name)
The tag name in the tags table and the genre column from the torrents is identical.
The $tags variable stores all the title tag about the current release
Sort similar releases by tags
So that the query searches from two existing tags in the current distribution and shows 10 suitable options with pictures and with the name of the movie (sql query will be enough) I can display the result itself thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bobur Bakhritdinov, 2015-12-13
@bakhritdinov_b

Solved the problem on my own!

$sql = $db->query($query);
$arr  = $db->get_row($sql
$genre = explode(',', $arr['genre']);
$query  = "SELECT 	id, image, name, genre  FROM `torrents` WHERE genre LIKE '%".$genre[1]."%' OR '%".$genre[2]."%' LIMIT 10";

D
Dmitry Kovalsky, 2015-12-13
@dmitryKovalskiy

Your Russian language is apparently not native. Let's assume that I understand you.

SELECT what you need FROM torrents as to
INNER JOIN tags as ta ON ta.id = to.genre
WHERE ta.name = something

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question