// 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 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 catalog.item_category LIKE ‘Antenna%’ AND items.name = catalog.item_name” ;
$result = mysql_query($sql, $conn) or trigger_error(“SQL”, E_USER_ERROR);
$numrows = (mysql_num_rows($result)) ;
$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;
// 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 catalog.item_category = 'Test Equipment' AND items.name = catalog.item_name ORDER BY catalog.item_manufact LIMIT $offset, $rowsperpage" ;
$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 catalog.item_category LIKE 'Antenna%' AND items.name = catalog.item_name ORDER BY catalog.item_manufact LIMIT $offset, $rowsperpage" ;
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$num_rows = mysql_num_rows($result);
?>