id_p mysql_fetch_assoc mysql_query SELECT cat FROM playground WHERE id

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$id_p = mysql_fetch_assoc(mysql_query("SELECT cat FROM `playground` WHERE `id` = '" . intval($_GET['i']) . "' LIMIT 1"));
$sql = mysql_query("SELECT `b`.`id` FROM `playground` AS `p`, `my_banner` AS `b`, `user` AS `u`
WHERE
`u`.`credit` > '0'
AND
`b`.`limit_credits` > `b`.`today_raskhod_credits`
AND
`b`.`status` = '1'
AND
`b`.`mod` = '1'
AND
`b`.`site` != '" . $_SERVER['HTTP_HOST'] . "'
AND
`b`.`forbidden` != '" . intval($_GET['i']) . "'
AND
`u`.`blocking` = '0'
AND
(`b`.`country` LIKE '%" . $strana_name . "%' OR `b`.`country` IS NULL)
AND
(`b`.`os` LIKE '%" . platforms() . "%' OR `b`.`os` IS NULL)
AND
`b`.`cat` LIKE '%" . $id_p['cat'] . "%'
ORDER BY RAND() LIMIT 1
");
if (mysql_num_rows($sql)) {
$sql = mysql_fetch_assoc($sql);
$id_banner = mysql_fetch_assoc(mysql_query("SELECT * FROM `my_banner` WHERE `id` = '" . $sql['id'] . "' LIMIT 1"));
echo $id_banner['name'].'<br>'.$id_banner['user_id'].'';
} else {
noBaner();
}