0% found this document useful (0 votes)
10 views

php CODE

The document is a PHP script that connects to a MySQL database to retrieve and display the latest food items in a store. It includes error reporting, pagination for product listings, and HTML structure for the web page. Additionally, it provides user guidance on navigating the site and accessing product details.

Uploaded by

20danyeer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

php CODE

The document is a PHP script that connects to a MySQL database to retrieve and display the latest food items in a store. It includes error reporting, pagination for product listings, and HTML structure for the web page. Additionally, it provides user guidance on navigating the site and accessing product details.

Uploaded by

20danyeer
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

<?

php

// Script Error Reporting

error_reporting(E_ALL);

ini_set('display_errors', '1');

?>

<?php

// Run a select query to get my letest 6 items

// Connect to the MySQL database

include "storescripts/connect_to_mysql.php";

$dynamicList = "";

$per_page = 4; // number of product items to list per page...

$count = 0; // keep track of DB data array...

setcookie("page","1",time()+3600,'/'); // remember what page we are on...

$sql1 = mysql_query("SELECT count(*) as tot FROM products"); // count number of rows


returned in our query...

$total_row = mysql_fetch_assoc($sql1);

$tots = $total_row['tot'];

setcookie("tot_page",ceil($tots/$per_page),time()+3600,'/'); // remember the total number of


pages in all...

$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC limit


$per_page");

$productCount = mysql_num_rows($sql); // count the output rows...

if ($productCount > 0) {

$db_Arr = array();
while($row = mysql_fetch_assoc($sql)){

$db_Arr[$count]['id'] = $row["id"];

$db_Arr[$count]['product_name'] = $row["product_name"];

$db_Arr[$count]['price'] = $row["price"];

$db_Arr[$count]['date_added'] = strftime("%b %d, %Y", strtotime($row["date_added"]));

++$count;

for($i =0; $i < count($db_Arr);$i++){

$dynamicList .= '<table class="meallist" width="100%" border="0" cellspacing="0"


cellpadding="6">

<tr>

<td width="17%" valign="top"><a href="product.php?id=' . $db_Arr[$i]['id'] .


'"><img style="border:#666 1px solid;" src="inventory_images/' . $db_Arr[$i]['id'] . '.jpg"
alt="' . $db_Arr[$i]['product_name'] . '" width="130" height="102" border="1" /></a></td>

<td width="83%" valign="top">' . $db_Arr[$i]['product_name'] . '<br />

#' . $db_Arr[$i]['price'] . '<br />

<a href="product.php?id=' . $db_Arr[$i]['id'] . '">View Food Details</a></td>

</tr>

</table>';

else{

$dynamicList = "We have no Foods listed in our store yet";

}
mysql_close();

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<style type="text/css">

<!--

.style1 {color: #F0F0F0}

-->

</style>

<?php include_once('./includes/head_tag.inc.php'); ?>

<body>

<div id="templatemo_container">

<div id="templatemo_header_section">

</div>

<?php include('./includes/navigation.inc.php'); ?>


<div id="templatemo_header_pizza">

</div>

<div id="templatemo_content">

<div id="templatemo_content_left">

<div><a href="./storeadmin/index.php">Admin Login</a></div>

<?php echo "<p id='addlist' style='height:500px;'> $dynamicList </p>"; ?>

<div id="pagination"><a href="javascript:void(0);" class="link" id="prev"> &laquo; prev


</a><span>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</span><a href="javascript:void(0);"
class="link" id="next">next &raquo;</a></div>

</div>

<div id="templatemo_content_right">

<h2>Website Guides</h2>

<p>Here is a little guide to help you through the site for easy accessibility.</p>

<p>The page you are currently looking at only display five (5) of our latest food
available.</p>

<p>On the 'Products' link above beside the Home link displays all the foods we have for
order at the moment.</p>

<p>Click on the view Food details to see more information about the food. </p>

<p>from there you can either click to see an enlarger version of the food or/ and proceed
to ordering or buying of the food. </p>

<p>the site is an easy to use site please drop a comment with us, to help us serve you
better</p>
<a href="#"><img alt="Delivery Now" src="images/templatemo_pizza_delivery.jpg" /></a>

<?php include('./includes/soc_widget.inc.php'); ?>

</div>

<div id="templatemo_card"></div>

</div>

<div id="templatemo_container_end">

</div>

</div>

<?php include('./includes/footer.inc.php'); ?>

</div>

<div>

</div>

<span class="style1"></span>

</body>

</html>

You might also like