Manufacturer

[insert_php]
// database connection info
$conn = mysql_connect(‘localhost’, ‘newand7_phil’, ‘pat2013hm’) or trigger_error(“SQL”, E_USER_ERROR);
$db = mysql_select_db(“newand7_selling”,$conn) or trigger_error(“SQL”, E_USER_ERROR);

// find out how many rows are in the table

$sql = “select count(*) from items”;

$result = mysql_query($sql, $conn) or trigger_error(“SQL”, E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];
//echo “line Item rows = “. $numrows . “
“;
// number of rows to show per page
$rowsperpage = 9;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);

// get the current page or set a default
if (isset($_GET[‘currentpage’]) && is_numeric($_GET[‘currentpage’])) {
// cast var as int
$currentpage = (int) $_GET[‘currentpage’];
} else {
// default page num
$currentpage = 1;
} // end if

// if current page is greater than total pages…
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
} // end if
// if current page is less than first page…
if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; //echo "
Offset” .” ” . $offset;
//echo “
number of rows ” . $rowsperpage;

// get the info from the db

$sql = “SELECT items.name, items.quantity, items.sales_price, items.notes, catalog.item_category, catalog.item_descript, catalog.item_manufact, catalog.item_pdf, items.jpg_address FROM items, catalog WHERE items.name = catalog.item_name\n ORDER BY catalog.item_manufact LIMIT $offset, $rowsperpage”;

//$sql = “SELECT items.name, items.quantity, items.sales_price, items.notes, catalog.item_descript, catalog.item_category, catalog.item_manufact, catalog.item_pdf, items.jpg_address FROM items, catalog WHERE items.name = catalog.item_name\n ORDER BY catalog.item_category LIMIT 0, 10”;

$result = mysql_query($sql, $conn) or trigger_error(“SQL”, E_USER_ERROR);

$num_rows = mysql_num_rows($result);

?>

Manufacturer Part Description Quantity Price Notes PDF JPEG
“>“;
/****** build the pagination links ******/
// range of num links to show
$range = 3;

// if not on page 1, don’t show back links
if ($currentpage > 1) {
// show << link to go back to page 1 echo "
<< “;
// get previous page num
$prevpage = $currentpage – 1;
// show < link to go back to 1 page echo "< “;
} // end if

// loop to show links to range of pages around current page
for ($x = ($currentpage – $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [$x] “;
// if not current page…
} else {
// make it a link
echo ” $x “;
} // end else
} // end if
} // end for

// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo ” > “;
// echo forward link for lastpage
echo ” >> “;
} // end if
/****** end build pagination links ******/
[/insert_php]

© New And Used Inc. 2017