Number of days to go back

Prod types

Prod platforms

"; $days = (int)$_GET["days"]; $days = min($days,3*365); $platforms = implode(",",$_GET["platforms"]); $t = array(); foreach($_GET["types"] as $t2) $t[] = "'".mysql_real_escape_string($t2)."'"; $types = implode(",",$t); //$sql = "select * from platforms"; //$r = mysql_query($sql) or die(mysql_error()." - ".$sql); $sql = "select prods.id,prods.name,g1.name as g1,g2.name as g2,g3.name as g3 from prods ". " LEFT JOIN groups AS g1 ON prods.group1 = g1.id". " LEFT JOIN groups AS g2 ON prods.group2 = g2.id". " LEFT JOIN groups AS g3 ON prods.group3 = g3.id". " JOIN prods_platforms ON prods.id = prods_platforms.prod ". " WHERE (UNIX_TIMESTAMP()-UNIX_TIMESTAMP(prods.date))<=".$days."*60*60*24 ". " AND prods_platforms.platform IN (".mysql_real_escape_string($platforms).") ". " AND FIND_IN_SET(".$types.",prods.type) ". " GROUP BY prods.id ORDER BY prods.name"; $r = mysql_query($sql) or die(mysql_error()." - ".$sql); ?> g1) $g[] = $o->g1; if ($o->g2) $g[] = $o->g2; if ($o->g3) $g[] = $o->g3; $groups = implode(", ",$g); $s = sprintf("select platforms.name from prods_platforms, platforms where prod = %d and platforms.id = prods_platforms.platform",$o->id); $r2 = mysql_query($s); $plat = array(); while($o2 = mysql_fetch_object($r2)) $plat[] = $o2->name; echo " \n"; printf(" %s\n",utf8_encode(htmlspecialchars($o->name)) ); if ($groups) printf(" %s\n",utf8_encode(htmlspecialchars($groups)) ); printf(" %s\n",utf8_encode(htmlspecialchars(implode(", ",$plat))) ); echo " \n"; } ?>