<?php
function fatawa_cats() {
global  $htmlorphp,$fatawa_catsloop,$LANGAUGE;

if($fatawa_catsloop=="1"){$width = "100%";}
elseif($fatawa_catsloop=="2"){$width = "50%";}
elseif($fatawa_catsloop=="3"){$width = "33%";}
elseif($fatawa_catsloop=="4"){$width = "25%";}
elseif($fatawa_catsloop=="5"){$width = "20%";}
elseif($fatawa_catsloop=="6"){$width = "16%";}
else{$width = "";}

$sql = @mysql_query("SELECT * FROM  fatawa_cat where sub='0' AND active='1' order by order_cat");
$nuc = mysql_num_rows($sql);
if($nuc == 0){
$printcats = $LANGAUGE[91];
}else{
$printcats = "<table border='0' width='100%' id='AutoNumber2' style='border-collapse: collapse'>";
$tslsls = '0';
while ($Row2 = @mysql_fetch_array($sql))
{
$sql2 = @mysql_query("SELECT * FROM fatawa where cat='".$Row2['id']."' AND active='1'");
$nu = mysql_num_rows($sql2);

++$tslsls;
if($tslsls=="$fatawa_catsloop"){
$tslslats = "</tr><tr>";
$tslsls="0";
}else{
$tslslats = "";
}

$Row2[name_cat] = text(3,$Row2[name_cat]);

if ($htmlorphp=="1"){
$printcats .= "<td width='$width' class='category'><div><a href='fatawa_cat-$Row2[id].html'>$Row2[name_cat]</a></div></td>
$tslslats";
}else{
$printcats .= "<td width='$width' class='category'><div><a href='fatawa.php?action=fatawa&id=$Row2[id]'>$Row2[name_cat]</a></div></td>
$tslslats";
}
}
$printcats .= "</table>";
}
return $printcats;
}








function fatawa() {
global $id,$htmlorphp,$folder,$fatawa_catsloop,$fatawa_loop,$LANGAUGE;

if($fatawa_catsloop=="1"){$width = "100%";}
elseif($fatawa_catsloop=="2"){$width = "50%";}
elseif($fatawa_catsloop=="3"){$width = "33%";}
elseif($fatawa_catsloop=="4"){$width = "25%";}
elseif($fatawa_catsloop=="5"){$width = "20%";}
elseif($fatawa_catsloop=="6"){$width = "16%";}
else{$width = "";}

$sql22 = @mysql_query("SELECT * FROM  fatawa_cat where sub='$id' AND active='1' order by order_cat");
$nuc = mysql_num_rows($sql22);
if($nuc == 0){
$printcats = "";
}else{
$printcats = "<table border='0' width='100%' id='AutoNumber2' style='border-collapse: collapse'>";
$tslsls = '0';
while ($Row2 = @mysql_fetch_array($sql22))
{
$sql2 = @mysql_query("SELECT * FROM fatawa where cat='".$Row2['id']."' AND active='1'");
$nu = mysql_num_rows($sql2);

++$tslsls;
if($tslsls=="$fatawa_catsloop"){
$tslslats = "</tr><tr>";
$tslsls="0";
}else{
$tslslats = "";
}

$Row2[name_cat] = text(3,$Row2[name_cat]);

if ($htmlorphp=="1"){
$printcats .= "<td width='$width' class='category'><div><a href='fatawa_cat-$Row2[id].html'>$Row2[name_cat]</a></div></td>
$tslslats";
}else{
$printcats .= "<td width='$width' class='category'><div><a href='fatawa.php?action=fatawa&id=$Row2[id]'>$Row2[name_cat]</a></div></td>
$tslslats";
}
}
$printcats .= "</table>";
}











$page = (int) (!isset($_GET["page"]) ? 1 : $_GET["page"]);
$page = ($page == 0 ? 1 : $page);
$perpage = $fatawa_loop;
$startpoint = ($page * $perpage) - $perpage;

$sql = @mysql_query("SELECT id,name,cat,vis,name_mfti,title FROM  fatawa where cat='$id' AND active='1' order by id desc limit $startpoint,$perpage");
$nucx = mysql_num_rows($sql);

if($nuc != 0 AND $nucx != 0){
$printcats .= "<br />";
}

if($nucx == 0){
if($nuc==0){
$printcats .= $LANGAUGE[118];
}else{
$printcats .= "";
}
}else{
$printcats .= "<ul>";
while ($Row = @mysql_fetch_array($sql))
{
$Row[name] = text(3,$Row[name]);
$Row[title] = text(3,$Row[title]);
$Row[name_mfti] = text(3,$Row[name_mfti]);

if($Row[title]==""){
$rq = $Row[name];
}else{
$rq = $Row[title];
}

if ($htmlorphp=="1"){
$lli = "<a href='fatawa_show-$Row[id].html'>".$rq."</a>";
}else{
$lli = "<a href='fatawa.php?action=fatawa_show&id=$Row[id]'>".$rq."</a>";
}

//$printcats .= "<li>".substr($lli,0,90)." [ ".$Row[vis]." ]</li>";
$printcats .= "<li>".$lli." <small>[ ".$Row[vis]." ]</small></li>";
}

$printcats .= "</ul>";

$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `fatawa` where cat='$id' AND active='1'")) / $perpage);
@mysql_free_result($pagesnum);

if($pagesnum > 1){
$printcats .= "<div class='multipage'>";
for ($i=1; $i<=$pagesnum; $i++) {
if ($i != $page) {

if ($htmlorphp=="1"){
$z = "<span><a href='fatawapage-$id-$i.html'>$i</a></span>";
}else{
$z = "<span><a href='fatawa.php?action=fatawa&id=$id&page=$i'>$i</a></span>";
}

} else {
$z = "<span class='act'>$i</span>";
}
$printcats .= "$z";

}
$printcats .= "</div>";
}
}
return $printcats;
}
?>