Use Next, Previous and page numbers to navigate through stock - click on images or carpet names to access item details - use Sort links to change display order

'; // print the top page nav echo '
'; // Show the page numbers // echo "$rowsFound carpets were found from " . $originName . "\n
"; // Are there any previous pages? if ($rowOffset > 0) // Yes, so create a previous link echo "\n\tPrevious "; else // No, there is no previous page so don't // print a link echo "Previous "; // Output the page numbers as links // Count through the number of pages in the results for($x=0, $page=1; $x<$rowsFound; $x+=ROWS, $page++) // Is this the current page? if ($x < $rowOffset || $x > ($rowOffset + ROWS - 1)) // No, so print out a link echo "" . $page . " "; else // Yes, so don't print a link echo $page . " "; // Are there any Next pages? if ($rowsFound > $nextOffset) // Yes, so create a next link echo "\n\tNext "; else // No, there is no next page so don't // print a link echo "Next "; echo '
'; // print the sort links echo '
'; echo 'Sort by:'; echo " LENGTH |"; echo " WIDTH |"; echo " PRICE |"; echo " ORIGIN |"; echo " NAME |"; // echo " RANDOM"; echo '
'; echo '
'; echo "
\n"; // start the imagedisplay div // Display one page of images and details in a div for ( $rowCounter = 0; (($rowCounter < ROWS) && ($row = @ mysql_fetch_array($result)) ); $rowCounter++) { echo "

\n"; echo "\"{$row['carpet_name']}\"\n"; echo "
{$row['age_name']} {$row['carpet_name']}\n"; $cml = $row['cm_length']; $cmw = $row['cm_width']; echo "
" . $cml . "x" . $cmw . " cm"; list ($ftl, $inl) = feet_inches ($cml); list ($ftw, $inw) = feet_inches ($cmw); echo " | " . $ftl . "'" . " " . $inl . """ . " x " . $ftw . "'" . " " . $inw .""\n"; echo "
{$row['origin_name']} "; echo "Sold (£{$row['s_price']})"; } else { echo "\"sprice\">£{$row['s_price']}"; } echo ""; echo "

\n"; } // end for rows in the page echo "
\n"; // end of imagedisplay div echo '
'; // print the bottom page nav echo '
'; // Show the row numbers that are being viewed // echo ($rowOffset + 1) . "-" . // ($rowCounter + $rowOffset) . " of "; // echo "$rowsFound items found from " . $originName . // "\n
"; // Are there any previous pages? if ($rowOffset > 0) // Yes, so create a previous link echo "\n\tPrevious "; else // No, there is no previous page so don't // print a link echo "Previous "; // Output the page numbers as links // Count through the number of pages in the results for($x=0, $page=1; $x<$rowsFound; $x+=ROWS, $page++) // Is this the current page? if ($x < $rowOffset || $x > ($rowOffset + ROWS - 1)) // No, so print out a link echo "" . $page . " "; else // Yes, so don't print a link echo $page . " "; // Are there any Next pages? if (($row != false) && ($rowsFound > $nextOffset)) // Yes, so create a next link echo "\n\tNext "; else // No, there is no next page so don't // print a link echo "Next "; echo '
'; // print the sort links echo '
'; echo 'Sort by:'; echo " LENGTH |"; echo " WIDTH |"; echo " PRICE |"; echo " ORIGIN |"; echo " NAME |"; //echo " RANDOM"; echo '
'; echo '
'; } // end if rowsFound != 0 else { echo "
No carpets found from the origin you searched \n"; } // Create a link back to the query input page echo "
Home Page
"; } $scriptName = "index.php"; $originName = 'All'; /* set the allowed order */ $random = 'rand()'; //$default_sort = 'carpet_name'; $default_sort = $random; $allowed_order = array ('carpets.s_price', 'carpets.carpet_name','carpets.price_id', 'carpets.cm_length', 'carpets.cm_width', 'carpets.origin_id', $random); /* if order is not set, or it is not in the allowed * list, then set it to a default value. Otherwise, * set it to what was passed in. */ if (!isset ($_GET['order']) || !in_array ($_GET['order'], $allowed_order)) { $order = $default_sort; } else { $order = $_GET['order']; } // Set $offset to zero if not previously set if (empty($offset)) $offset = 0; // Build the query $query = "SELECT * FROM carpets, origins, ages, types WHERE origins.origin_id = carpets.origin_id AND ages.age_id = carpets.age_id AND types.type_id = carpets.type_id"; // Add a sort on the end of the query // $query .= " ORDER by carpets.$order"; $query .= " ORDER by $order"; $result = mysql_query ($query); $row = mysql_fetch_array ($result); // Initialize the browse() function parameters $originName = $row['origin_name']; $cml = $row['cm_length']; $cmw = $row['cm_width']; // Query prefix for the next/previous links including the order param $browseString = "originName=" . rawurlencode($originName) . "&order=" . rawurlencode($order); // Page header for the browse screen $pageHeader = "

"; $pageHeader.= "Oriental Rug Shopping Gallery"; $pageHeader.= "

"; // Call generic browsing code to browse query browse($scriptName, $connection, $browseString, $offset, $query, $pageHeader, $originName, $cml, $cmw,$order); include_once ('footer-a.php'); // Require the 1 column footer. ob_end_flush(); // Send everything to the Web browser. ?>