Jump to content

Recommended Posts

 

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.

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";
	}
}




}







//}

?>

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.