April 28, 2009, 7:49 pm
It is actually very simple. All you need to know is what page you are on and how many items there is to list in total. Here is an out line:
Step one, get those values:
total_items
items_per_page
current_page
Step two, calculate total pages:
total_pages = ( total_items / items_per_page )
Step three, calculate limit offset for database query:
start_item = current_page * items_per_page
end_item = if on last page then ( total_pages – start_item ) else ( items_per_page ) “asuming your database works like mysql”
Be mindful that arrays and databases start from 0 not from 1.
And from there just make your PHP code and add on nifty features of your own.
Check out my previous guide for a nice pagination script with demo.
January 6, 2009, 8:24 pm
My internet provider is not one of the best for one damn reason: It has bandwidth limit. So there I was wondering how am I going to transfer my 15gb website from old location to this shiny new one, knowing I have only 1GB on my monthly bandwidth left and it resets about 10 days from now. First attempt is to use one of those web ftp websites i found, well they all got their own bandwidth or they just freeze. I tried connecting to the old website using my own ftp script but it failed, and so did the remade scripts I tried using. The conclusion is that the old website does not allow direct ftp or special access, but my new one is liek a free world, do what you want sorta thing. Problem solved! I made mini script for teh old website that shows all files and folders in an orderly fashion in a big list. Then I made a simple file_get_content() and file_put_content() script on my new site. It was perfect, thought the rapid request rate shuts down the only connection between my two websites. Added a sleep(1) right after each download and flush() right after it is echo ‘file copied’ and it was done. Just sit back and relax as my new site copied all the files nice and fast. Continue reading ‘PHP Website To Website File Transfer’ »
January 2, 2009, 2:34 pm
At some point I needed to paginate my results of a large database for a more friendly view. Now I use PHP so this tutorial will fully explain how to paginate using php and SQL database, or just an array with all the data. That way you can use the technique with any other database you like. I will go over the basic mechanics and the add nice things on top like pagination and sorting at the same time and how to build a wicked page navigation for the listing. And also I shall show you how to make a so called server side pagination/sorting using Ajax JavaScript at the end. Continue reading ‘PHP Pagination Guide’ »
January 2, 2009, 4:12 am
My first website was the most confusing piece of code ever. During my time of writing it I learned some usual things and the common used things. I’ll share some of the nice ways to organize your website structure. Those structures may be simple but effective for your own use. Since I am a PHP power user, I’ll make it a PHP based tutorial. In my point of view, having all pages loaded from index is the best for massive websites. That is because you do not share the internal folders with users and everybody uses one single page for viewing, meaning you can password protect everything else on your server. Continue reading ‘PHP Website Structure and Design’ »
July 28, 2008, 9:52 pm
Written by Joe
Every year, countless lives are lost to heart failure. The cause of this failure is the extra strain on the heart due to lack of exercise and good eating habits.

Continue reading ‘Why We Should Eat Right and Stay Fit’ »