<?PHP
if ($_POST[limit] != $nil)
        $_SESSION['limit'] = $_POST['limit'];
if ($_SESSION[limit] == $nil)
        $_SESSION['limit'] = 10;
?> 
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr> 
<td class="td4"><span class="link5"> 
<?php category_header($_GET[category],home,browse,category,$rowxxx[MR]); ?>
</span></td>
</tr>
</table>
<br>
<?PHP
//--------------------------------
if ($rowxxx[PD] == '') {
?>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>

<?PHP }
//--------------------------------
?>

<?PHP
//--------------------------------

if ($rowxxx['SORT'] == 'Alphabetical')
        $rowxxx['SORT'] = 'ORDER BY HEADER ASC';
if ($rowxxx['SORT'] == 'Newest First')
        $rowxxx['SORT'] = 'ORDER BY ID DESC';
if ($rowxxx['SORT'] == 'Oldest First')
        $rowxxx['SORT'] = 'ORDER BY ID ASC';

$sort = $rowxxx['SORT'];

$table = "PAGES";
$string = "WHERE CATEGORY LIKE '%-$_GET[category]-%'";

$swap = "&page=$_GET[page]&category=$_GET[category]";


$r = $rowxxx[R];
if ($rowxxx[R] == '') $r = 2;

if ($r == 1)  $w = '100%';
if ($r == 2)  $w = '50%';
if ($r == 3)  $w = '33%';
if ($r == 4)  $w = '25%';
if ($r == 5)  $w = '20%';

?>

<?PHP
//-------------------------------------------

        $query1         = @mysql_query ("SELECT * FROM $table $string $sort");
        $numrows        = @mysql_num_rows ($query1);
        if (!isset ($_GET['show'])) {
                $display = 1;
        } else {
                $display = $_GET['show'];
        }

        $start          = (($display * $_SESSION['limit']) - $_SESSION['limit']);
        $query2         = @mysql_query ("SELECT * FROM  $table $string $sort LIMIT $start,$_SESSION[limit]");

        $counter = '0';
        while ($row = @mysql_fetch_array ($query2)) {
                if ($counter == $r) $counter = 0;
                $pieces = explode("-", $row[CATEGORY]);

                if ($rowxxx[PD] == '') echo "<td width=$w>";
                include "browse_display$rowxxx[PD].php";
                


                if ($rowxxx[PD] == '') {
                        echo "</td>";

                $set = $r;
                $r = $r - 1;

                if ($counter < $r) {
                        echo '<td><img src="images/transparent.gif" width="15" height="10"></td>';
                }

                if ($counter == $r) {

                        echo '<tr>
                        <td height="15"><img src="images/transparent.gif" width="15" height="15"></td>
                        <td><img src="images/transparent.gif" width="15" height="15"></td>';
                        echo "</tr><tr>";
                        }
                        $counter = $counter + 1;

                }
        $r = $set; }

//---------------------------
?>

<?PHP
if ($rowxxx[PD] == '') {
?>
</table>
<?PHP } ?>

<?php if ($numrows == '0') { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="td4">No videos found.</td>
</tr>
</table>
<?php if (empty($_GET[category])) ?>
<?PHP } else { ?>
<?php if ($rowxxx[PD] == '') echo "<br>"; ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form action="?show=1&amp;page=browse&amp;category=<?php echo $_GET[category]; ?>&amp;mode=<?php echo $_GET[mode]; ?>" method="post" name="form" id="form">
<tr>
<td class="td4" align="right">
<input type="submit" name="Submit" value="Show" />
<select name="limit">
<option selected>
<?php echo $_SESSION['limit']; ?>
</option>
<option>1</option>
<option>5</option>
<option>10</option>
<option>20</option>
<option>30</option>
<option>50</option>
<option>100</option>
</select>
Videos per <span class="link2"> 
<?php include "pagination_bot.php"; ?>
</span> </td>
</form>
</table>
<?PHP } ?>
