TheVoice Posted January 4, 2008 Share Posted January 4, 2008 http://tinyurl.com/3yc8wa/test_Catalog.php Hi. I have been trying to design a simple php catalog forever. I just wanted about 14 items in an array to be listed like google search results would be listed for instance. I made the code so that nine "products" would be align in a 3x3 arrangement. There would also be links at the bottom of the page, but the problem is that the links that the php code creates go to a different php page (as you can see from viewing the address bar after clicking the links) which still starts from the first item in the list of the array and not the 10 item (as should happen when moving to what should be the second page of this very basic catalog). I eventually want to use this code to list things from my MYSQL database which we won't have to talk about in this topic right now. Is there any open source website that offers a catalog that lists results in this ways that is readily "tweakable". I have tried for weeks and still cannot come up with how to change between products listed in my array. Your help would be much appreciated. Thank you all. Quote Link to comment https://forums.phpfreaks.com/topic/84443-my-catalog-code-wont-work-fullyplease-help/ Share on other sites More sharing options...
Ken2k7 Posted January 4, 2008 Share Posted January 4, 2008 This looks to be a pagination and SQL limit problem. Can you post your full code? Quote Link to comment https://forums.phpfreaks.com/topic/84443-my-catalog-code-wont-work-fullyplease-help/#findComment-430135 Share on other sites More sharing options...
TheVoice Posted January 4, 2008 Author Share Posted January 4, 2008 the code is below: <title></title> <?php $start=1; $tube=1; // this variable represents the current page that the customer is on $repz=$start+9; $derka=14; // the total number of products $box_per_page=9; $pages=ceil($derka/$box_per_page); $sugar = array(1=>one,2=>two,3=>three,4=>four,5=>five,6=>six,7=>seven,8=>eight,9=>nine,10=>ten,11=>eleven,12=>twelve,13=>thirteen,14=>fourteen); //if ($tube == 1){ // $start=10; //} // code to create number of individual pages! //for ($p=0;$p<$pages;$p++){ //$tube++; echo "<html>"; echo "Catalog on tube $tube"; echo "<table height='70%' width='70%' align='center'>"; // code for each individual product to be arranged correctly per page for ($n=$start;$n < $repz;$n++){ if ($n==$start){ echo "<tr>"; } echo "<td>$sugar[$n]</td>"; if (is_int($n/3) and $n>1){ echo "</tr><tr>"; } if (is_int($n/$box_per_page) and $n>1){ echo "</table>"; $end=$n; if ($tube > 1 and (($tube - 1) != 0)) { $url = "test_Catalog.php?tube=" . $tube - 1; echo "<a href=\"$url\">Previous</a>\n"; } // page numbering links now for ($i = 0; $i < $pages; $i++) { $url = "test_Catalog.php?tube=" . $i; echo " | <a href=\"$url\">$i</a> | "; } if ($tube < $pages) { $url = "test_Catalog.php?tube=" . $tube + 1; echo "<a href=\"$url\">Next</a>\n"; echo "</html>"; } if ($start < $derka){ $start=$end+1; echo "the variable start equals $start"; } } } //} ?> Quote Link to comment https://forums.phpfreaks.com/topic/84443-my-catalog-code-wont-work-fullyplease-help/#findComment-430146 Share on other sites More sharing options...
Ken2k7 Posted January 4, 2008 Share Posted January 4, 2008 First off, (I haven't looked through the whole thing yet) but shouldn't the array: $sugar = array(1=>one,2=>two,3=>three,4=>four,5=>five,6=>six,7=>seven,8=>eight,9=>nine,10=>ten,11=>eleven,12=>twelve,13=>thirteen,14=>fourteen); have the text be in quotes? And you really don't need to say 1=>"one". By default, it will be that. Also, for this pagination system to work, you'll most likely need your data to be in the database. Quote Link to comment https://forums.phpfreaks.com/topic/84443-my-catalog-code-wont-work-fullyplease-help/#findComment-430152 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.