how to make something like this

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
neliconcept
Forum Newbie
Posts: 2
Joined: Sun Jul 07, 2002 5:38 pm

how to make something like this

Post by neliconcept »

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?
User avatar
cheatboy00
Forum Contributor
Posts: 151
Joined: Sat Jun 29, 2002 10:36 am
Location: canada
Contact:

Post by cheatboy00 »

you would somehow have to check each character in the title....

try seaching in the php manul for somethign anlong the lines of strchr or somethign like that
User avatar
QWERTY
Forum Newbie
Posts: 20
Joined: Sat Jun 29, 2002 10:57 am
Location: Slovenia

...

Post by QWERTY »

Try with SQL (ORDER BY field_with_title ASC / DESC)...
I don't now if it will work, but you can try...
neliconcept
Forum Newbie
Posts: 2
Joined: Sun Jul 07, 2002 5:38 pm

Post by neliconcept »

well im a newb so i dont know what you are really talking about since i only did my site in php the easy php thats all i really know
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I would check out a few tutorials, try places like: As you've discovered, it's difficult to get help if you don't understand the answers. A few tutorials should help you get your database started and then if you have problems feel free to come back here and ask.

Mac
ajaypatil
Forum Newbie
Posts: 17
Joined: Wed Jul 03, 2002 2:15 am
Location: Pune, India
Contact:

Re: how to make something like this

Post by ajaypatil »

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.

:lol:
Ajay
Post Reply