Product-function . php ?php Add . php ?php

if numDeleted == numItem { if all item deleted return to the last page that the customer visited before going to shopping cart headerLocation: returnUrl . _SESSION[shop_return_url]; } else { headerLocation: cart.php; } exit; } function isCartEmpty { isEmpty = false; sid = session_id; sql = SELECT ct_id FROM tbl_cart ct WHERE ct_session_id = sid; result = dbQuerysql; if dbNumRowsresult == 0 { isEmpty = true; } return isEmpty; } Delete all cart entries older than one day function deleteAbandonedCart { yesterday = dateY-m-d H:i:s, mktime0,0,0, datem, dated - 1, dateY; sql = DELETE FROM tbl_cart WHERE ct_date yesterday; dbQuerysql; } ? 17. Product-function . php ?php require_once config.php; PRODUCT FUNCTIONS Get detail information of a product function getProductDetailpdId, catId { Universitas Sumatera Utara _SESSION[shoppingReturnUrl] = _SERVER[REQUEST_URI]; get the product information from database sql = SELECT pd_name, pd_description, pd_price, pd_image, pd_qty FROM tbl_product WHERE pd_id = pdId; result = dbQuerysql; row = dbFetchAssocresult; extractrow; row[pd_description] = nl2brrow[pd_description]; if row[pd_image] { row[pd_image] = WEB_ROOT . imagesproduct . row[pd_image]; } else { row[pd_image] = WEB_ROOT . imagesno-image-large.png; } row[cart_url] = cart.php?action=addp=pdId; return row; } ? 18. Add . php ?php if definedWEB_ROOT { exit; } parentId = isset_GET[parentId] _GET[parentId] 0 ? _GET[parentId] : 0; ? form action=processCategory.php?action=add method=post enctype=multipartform-data name=frmCategory id=frmCategory p align=center class=formTitleAdd Categoryp table width=100 border=0 align=center cellpadding=5 cellspacing=1 class=entryTable tr td width=150 class=labelCategory Nametd td class=content input name=txtName type=text class=box id=txtName size=30 maxlength=50td tr tr td width=150 class=labelDescriptiontd td class=content textarea name=mtxDescription cols=50 rows=4 class=box id=mtxDescriptiontextareatd Universitas Sumatera Utara tr tr td width=150 class=labelImagetd td class=content input name=fleImage type=file id=fleImage class=box input name=hidParentId type=hidden id=hidParentId value=?php echo parentId; ?td tr table p align=center input name=btnAddCategory type=button id=btnAddCategory value=Add Category onClick=checkCategoryForm; class=box nbsp;nbsp;input name=btnCancel type=button id=btnCancel value=Cancel onClick=window.location.href=index.php?catId=?php echo parentId; ?; class=box p form 19. List . php ?php if definedWEB_ROOT { exit; } if isset_GET[catId] int_GET[catId] = 0 { catId = int_GET[catId]; queryString = catId=catId; } else { catId = 0; queryString = ; } for paging how many rows to show per page rowsPerPage = 5; sql = SELECT cat_id, cat_parent_id, cat_name, cat_description, cat_image FROM tbl_category WHERE cat_parent_id = catId ORDER BY cat_name; result = dbQuerygetPagingQuerysql, rowsPerPage; pagingLink = getPagingLinksql, rowsPerPage; ? pnbsp;p Universitas Sumatera Utara form action=processCategory.php?action=addCategory method=post name=frmListCategory id=frmListCategory table width=100 border=0 align=center cellpadding=2 cellspacing=1 class=text tr align=center id=listTableHeader tdCategory Nametd tdDescriptiontd td width=75Imagetd td width=75Modifytd td width=75Deletetd tr ?php cat_parent_id = 0; if dbNumRowsresult 0 { i = 0; whilerow = dbFetchAssocresult { extractrow; if i2 { class = row1; } else { class = row2; } i += 1; if cat_parent_id == 0 { cat_name = a href=\index.php?catId=cat_id\cat_namea; } if cat_image { cat_image = WEB_ROOT . imagescategory . cat_image; } else { cat_image = WEB_ROOT . imagesno-image-small.png; } ? tr class=?php echo class; ? td?php echo cat_name; ?td td?php echo nl2brcat_description; ?td td width=75 align=centerimg src=?php echo cat_image; ?td td width=75 align=centera href=javascript:modifyCategory?php echo cat_id; ?;Modifyatd Universitas Sumatera Utara td width=75 align=centera href=javascript:deleteCategory?php echo cat_id; ?;Deleteatd tr ?php } end while ? tr td colspan=5 align=center ?php echo pagingLink; ?td tr ?php } else { ? tr td colspan=5 align=centerNo Categories Yettd tr ?php } ? tr td colspan=5nbsp;td tr tr td colspan=5 align=right input name=btnAddCategory type=button id=btnAddCategory value=Add Category class=box onClick=addCategory?php echo catId; ? td tr table pnbsp;p form 20. Categorylist . php ?php if definedWEB_ROOT { exit; } categoryList = getCategoryList; categoriesPerRow = 3; numCategory = countcategoryList; Universitas Sumatera Utara columnWidth = int100 categoriesPerRow; ? table width=100 border=0 cellspacing=0 cellpadding=20 ?php if numCategory 0 { i = 0; for i; i numCategory; i++ { if i categoriesPerRow == 0 { echo tr; } we have url, image, name, price extract categoryList[i]; echo td width=\columnWidth\ align=\center\a href=\url\img src=\image\ border=\0\brnameatd\r\n; if i categoriesPerRow == categoriesPerRow - 1 { echo tr; }} if i categoriesPerRow 0 { echo td colspan= . categoriesPerRow - i categoriesPerRow . nbsp;td; } } else { ? trtd width=100 align=center valign=centerNo categories yettdtr ?php } ? table 21. Shippingandpaymentinfo . php ?php