neliconcept wrote:ok im trying to make a tutorials sectoin at my site and also keep 3 tutorials per page but i would like to make a some sort of database to make the tutorials go in alphabetical order or a-z z-a or most downloaded but keep 3 per page or 6 per page or 10 per page how would i do this?
Make a table called Tutorials, which as columns like:
- ID, Name, Summary, Download_Count, Content.
Then You can write a PHP Script -
ViewTutorials.php
Inside ViewTutorials.php write code like:
Code: Select all
$sql = "SELECT Content FROM Tutorials
ORDER BY $sort_key $sort_order
LIMIT $start_row, $tutorials_perpage";
$sort_key, $sort_order, $start_row and $row_count are
POST or GET Variables.
$sort_key equals to "Name" or "Download_Count".
$asc equals to "ASC" or "DESC" (ASC is a-z. DESC is z-a)
$tutorials_perpage can be 3,6 or 10.
$start_row is initialized to 0, and then subsequently incremented/
decremented for each next or previous link.
You can display the results from the above query on your
page. You can then give the Previous and next links like follows:
Code: Select all
<?php
$next_row = $start_row + $row_count;
$previous_row = $start_row - $row_count;
// Hyperlink to Next tutorials
echo "<a href="ViewTutorials.php?sort_key=$sort_key&sort_order=$sort_order&start_row=$next_row&row_count=$row_count">Next $row_count Tutorials</a>";
// Hyperlink to Previous Tutorials
echo "<a href="ViewTutorials.php?sort_key=$sort_key&sort_order=$sort_order&start_row=$previous_row&row_count=$row_count">Previous $row_count Tutorials</a>";
// Hyperlink to view Tutorials a-z
echo "<a href="ViewTutorials.php?sort_key=Name&sort_order=ASC&start_row=0&row_count=$row_count">Tutorials a-z</a>";
// Hyperlink to view Tutorials z-a
echo "<a href="ViewTutorials.php?sort_key=Name&sort_order=DESC&start_row=0&row_count=$row_count">Tutorials a-z</a>";
// Hyperlink to view Tutorials Top-Downloaded
echo "<a href="ViewTutorials.php?sort_key=Download_Count&sort_order=DESC&start_row=0&row_count=$row_count">Top downloaded Tutorials</a>";
Hope you can get this working pretty fast now and above was
exactly what you were looking for.
Ajay