Categorized | Affiliate Marketing 101

Show 10 Products Per Page, Then Auto Generate Another Page For Next 10 Porducts? Php?

Ok hey guys, thanks for reading this post. now what I am trying to do is simply displaying 10 products from the table and if more than 10 products are shown it will then automatically add a new page with like.. a different ID in the url? Well anything really as long as it will generate the pages dynamically. Below is my current coding.
$data = mysql_query(“SELECT * FROM products;”) or die(mysql_error());
$id = mysql_query(“SELECT ID FROM products;”) or die (mysql_error());
while($info = mysql_fetch_array( $data ))
{
echo ‘

‘;
echo “

“;
}
echo “

“;
echo ‘<a href="?page=products&uid='.$info['ID'].'…
Echo "
“;
echo “
“;
echo “

“;
Echo “Name: “.$info[‘name’] . “
“;
Echo “Price: “.$info[‘price’] . ”

“;
echo “

“;
Echo “Please click the image for further info.


“;
echo “


?>
As the coding shows, it is simply displaying the entire table in the PHP, however the problem is that the table will simply continue for ever, until their is no more products!! If you don’t know how to automatically generate a new page then would it be a good idea to show row 1-10, 11-20, 21-30 in different pages. If so how would this be done? Oops, I forgot to mention that the user will access the next list of products, E.G 11-20 by clicking the next page button.
Is it possible to use a get function to change the ID of the url when next page is clicked? then it will show the 11-20 results depending on the URL? eg products&id=2 therefore showing the next list of products? I am pretty confused hehe!:)
Thanks, your knowledge is appreciated!:)

No Responses to “Show 10 Products Per Page, Then Auto Generate Another Page For Next 10 Porducts? Php?”

  1. juliepel says:

    You should use MySql’s “LIMIT” keyword.
    Appending “LIMIT 20 , 10” would show you the third page of results. So you just need to add a simple parm to go next and previous, possibly the starting point (20 in the example).

  2. ltsephir says:

    In this case you would want to use a for loop:http://www.tizag.com/phpT/forloop.php
    Basically
    for ($counter <0; counter <10; counter++){
    (Whatever goes here)
    The next page would just do the same thing from 10-20, what would be better is to make it do from +10 of whereever the counter is onload of the page. Counter2 = counter for counter = (whatever) counter < counter2, counter++) etc. I think this should show you what you should need to know well enough.

Trackbacks/Pingbacks


Leave a Reply

Your email address will not be published. Required fields are marked *

Archives

Powered by Yahoo! Answers