Posts: 53
Joined: Feb 2010
Reputation: 0 Points: 76
PHP Help?
PHP Code:
<?php include("../config.php"); $sql = mysql_query("SELECT * FROM `ava_tags`"); $num = 0; $text = ""; while($a = mysql_fetch_array($sql)) { $as = mysql_query("SELECT * FROM `ava_tag_relations` where `tag_id` = '$a[id]'"); $as = mysql_num_rows($as); $min = 2; // the minmium of games that needs to be in that tag to be displayed. if($as > $min) { $num = $num+1; } } $col = $num / 4; $col = round($col);
$myfile1 = "tag_cloud_cache1.php"; $fh1 = fopen($myfile1, 'w') or die("can't open file"); $myfile2 = "tag_cloud_cache2.php"; $fh2 = fopen($myfile2, 'w') or die("can't open file"); $myfile3 = "tag_cloud_cache3.php"; $fh3 = fopen($myfile3, 'w') or die("can't open file"); $myfile4 = "tag_cloud_cache4.php"; $fh4 = fopen($myfile4, 'w') or die("can't open file"); $col1 = $col; $col2 = $col * 2; $col3 = $col * 3; $col4 = $col * 4; $numw = 0; while($a = mysql_fetch_array($sql)) { $as = mysql_query("SELECT * FROM `ava_tag_relations` where `tag_id` = '$a[id]'"); $as = mysql_num_rows($as); if($as > $min) { $numw = $numw+1; $tag_link = 'tag/'.seoname($a[tag_name]).$setting['seo_extension']; $string = '<a href="'.$setting['site_url'].'/'.$tag_link.'">' . $a[tag_name] . '</a><br /> '; if($numw <= $col1) { //less than 25? fwrite($fh1, $string) or die("can't open file"); echo "$a[tag_name]"; } elseif($col1 <= $numw && $numw <= $col2) { // more than 25 but less than 50 fwrite($fh2, $string) or die("can't open file"); echo "$a[tag_name]"; } elseif($col2 <= $numw && $numw <= $col3) { // more than 50 but less than 75 fwrite($fh3, $string) or die("can't open file"); echo "$a[tag_name]"; } elseif($col3 <= $numw && $numw <= $col4) { // more than 25 but less than 25 fwrite($fh4, $string) or die("can't open file"); echo "$a[tag_name]"; } else { } } } fclose($fh1); fclose($fh2); fclose($fh3); fclose($fh4);
<?php include("../config.php"); $sql = mysql_query("SELECT * FROM `ava_tags`"); $num = 0; $text = ""; while($a = mysql_fetch_array($sql)) { $as = mysql_query("SELECT * FROM `ava_tag_relations` where `tag_id` = '$a[id]'"); $as = mysql_num_rows($as); $min = 2; // the minmium of games that needs to be in that tag to be displayed. if($as > $min) { $num = $num+1; } } $col = $num / 4; $col = round($col);
$myfile1 = "tag_cloud_cache1.php"; $fh1 = fopen($myfile1, 'w') or die("can't open file"); $myfile2 = "tag_cloud_cache2.php"; $fh2 = fopen($myfile2, 'w') or die("can't open file"); $myfile3 = "tag_cloud_cache3.php"; $fh3 = fopen($myfile3, 'w') or die("can't open file"); $myfile4 = "tag_cloud_cache4.php"; $fh4 = fopen($myfile4, 'w') or die("can't open file"); $col1 = $col; $col2 = $col * 2; $col3 = $col * 3; $col4 = $col * 4; $numw = 0; while($a = mysql_fetch_array($sql)) { $as = mysql_query("SELECT * FROM `ava_tag_relations` where `tag_id` = '$a[id]'"); $as = mysql_num_rows($as); if($as > $min) { $numw = $numw+1; $tag_link = 'tag/'.seoname($a[tag_name]).$setting['seo_extension']; $string = '<a href="'.$setting['site_url'].'/'.$tag_link.'">' . $a[tag_name] . '</a><br /> '; if($numw <= $col1) { //less than 25? fwrite($fh1, $string) or die("can't open file"); echo "$a[tag_name]"; } elseif($col1 <= $numw && $numw <= $col2) { // more than 25 but less than 50 fwrite($fh2, $string) or die("can't open file"); echo "$a[tag_name]"; } elseif($col2 <= $numw && $numw <= $col3) { // more than 50 but less than 75 fwrite($fh3, $string) or die("can't open file"); echo "$a[tag_name]"; } elseif($col3 <= $numw && $numw <= $col4) { // more than 25 but less than 25 fwrite($fh4, $string) or die("can't open file"); echo "$a[tag_name]"; } else { } } } fclose($fh1); fclose($fh2); fclose($fh3); fclose($fh4);