Hey, i have made a tutorial system (Which is copyright and you are not allowed to use it as of yet, as i havn't released it... i may do in the near futre though.) But, now i have loads of tutorials being put on my web site, they are getting so far down the page, and I was wandering if someone could figure out a way to add a pagination to the pages, when you have clicked on a category to go to.
Here is the tutorial system:
Code:
<?php
include ("dbconnect.php");
switch ($view ) { // simple switch function
default: //states wat will show up if view doesn't = nething
$sql_query = "SELECT * FROM tutorials";
$result = mysql_query($sql_query);
$rows = mysql_num_rows($result);
echo "<center>There are currently <strong>($rows)</strong> tutorials all together<BR><BR></center>";
echo "<strong>Select type:</strong><br>";
echo "<a href=\"?nitr0x=tutorials/tutorials&view=all&sec=photoshop\">Photoshop</a> <br><a href=\"?nitr0x=tutorials/tutorials&view=all&sec=php\">PHP</a><br><a href=\"?nitr0x=tutorials/tutorials&view=all&sec=html\">HTML</a><br><a href=\"?nitr0x=tutorials/tutorials&view=all&sec=submitted\">Submitted</a>";
break;
case "all":
$sec = $_GET["sec"];
$get = "SELECT * FROM `tutorials` WHERE section='$sec'";
$go = mysql_query($get);
while ($adam = mysql_fetch_array($go)) {
$color_1 = "#921414";
$color_2 = "#CC1C1C";
static $color;
if ($color == $color_1) {
$color = $color_2;
}
else {
$color = $color_1;
/// $color
}
/////////// HTML BIT GOES HERE
?>
<table width="100%" bgcolor="<? echo "$color"; ?>" border="0" cellspacing="0" cellpadding="0" style="border-style: dashed; border-width: 1; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1">
<tr>
<td><strong><? echo "$adam[title]"; ?></strong></td>
</tr>
<tr>
<td>Submitted On: <? echo "$adam[date]"; ?></td>
</tr>
<tr>
<td>Description: <? echo "$adam[description]"; ?></td>
</tr>
<tr>
<td>Submitted By: <? echo "$adam[user]"; ?></td>
</tr>
<tr>
<td><a href="?x=tutorials/tutorials&view=view&id=<? echo "$adam[ID]"; ?>">View Tutorial</a></td>
</tr>
</table>
<br>
<?
//////////// END HTML PART
}
break; case "view":
$id = $_GET["id"]; // Sets the variable from the url - grabs the id # from url
$get = "SELECT * FROM `tutorials` WHERE ID='$id'"; // sql statement
$go = mysql_query($get); // retrieve the sql statment
while ($adam = mysql_fetch_array($go)) { // do this until finished
////////////// START HTML PARTS fOR VIEWING
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="right"><a href="?x=tutorials/tutorials"><strong>Tutorials</strong></a>
<strong>::</strong> <strong><? echo "<a href=\"?x=tutorials/tutorials&view=all&sec=$adam[section]\">$adam[section]</a>";
?></strong></div></td>
</tr>
<tr>
<td><div align="center"><strong>:: <? echo "$adam[title]"; ?> ::</strong></div></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><div align="left"><? echo "$adam[message]"; ?></div></td>
</tr>
<tr>
<Td>
<div align="right"><strong>Written by : <? echo "$adam[user]"; ?></strong></div>
</Td>
</tr>
</table>
<?
///////// END HTML PARTS FOR VIEWING OF TUTORIAL
}
}
?>
I'm guessing the pageination would be where the:
Code:
case "all":
$sec = $_GET["sec"];
$get = "SELECT * FROM `tutorials` WHERE section='$sec'";
$go = mysql_query($get);
while ($adam = mysql_fetch_array($go)) {
$color_1 = "#921414";
$color_2 = "#CC1C1C";
static $color;
if ($color == $color_1) {
$color = $color_2;
}
else {
$color = $color_1;
/// $color
}
/////////// HTML BIT GOES HERE
?>
<table width="100%" bgcolor="<? echo "$color"; ?>" border="0" cellspacing="0" cellpadding="0" style="border-style: dashed; border-width: 1; padding-left: 4; padding-right: 4; padding-top: 1; padding-bottom: 1">
<tr>
<td><strong><? echo "$adam[title]"; ?></strong></td>
</tr>
<tr>
<td>Submitted On: <? echo "$adam[date]"; ?></td>
</tr>
<tr>
<td>Description: <? echo "$adam[description]"; ?></td>
</tr>
<tr>
<td>Submitted By: <? echo "$adam[user]"; ?></td>
</tr>
<tr>
<td><a href="?x=tutorials/tutorials&view=view&id=<? echo "$adam[ID]"; ?>">View Tutorial</a></td>
</tr>
</table>
is... but i'm not too sure, if you can figure this out it would be so much appreciated, and you would get a mention on the site... and on the tutorial system if it gets released.
