Please kindly help me in checking out the codings.
Thanks.
The below is the side.php file
Code: Select all
<li class="color"><a href="<?php echo "m_category.php?product='agric'"; ?>">Agriculture</a></li>
<li><a href="<?php echo "m_category.php?product='apparel'"; ?>">Apparel</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='auto'"; ?>">Automobiles & Motorcycles</a></li>
<li><a href="<?php echo "m_category.php?product='chemicals'"; ?>">Chemicals</a></li>
<li class="color"><a href=<?php echo "m_category.php?product='computer'"; ?> >Computer Hardware & Software</a></li>
<li><a href="<?php echo "m_category.php?product='real_estate'"; ?>">Construction & Real Estate</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='consumer_elect'"; ?>">Consumer Electronics</a></li>
<li><a href="<?php echo "m_category.php?product='electrical'"; ?>">Electrical Equipment</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='fashion'"; ?>">Fashion Accessories</a></li>
<li><a href="<?php echo "m_category.php?product='food'"; ?>">Food & Beverage</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='furniture'"; ?>">Furniture</a></li>
<li><a href="<?php echo "m_category.php?product='gifts'"; ?>">Gifts & Crafts</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='health'"; ?>">Health & Medical</a></li>
<li><a href="<?php echo "m_category.php?product='home_appliance'"; ?>">Home Appliances</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='hotels'"; ?>">Hotels</a></li>
<li><a href="<?php echo "m_category.php?product='lights'"; ?>">Lights & Lighting</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='machinery'"; ?>">Machinery</a></li>
<li><a href="<?php echo "m_category.php?product='mechanical'"; ?>">Mechanical Parts </a></li>
<li class="color"><a href="<?php echo "m_category.php?product='office'"; ?>">Office & School Supplies</a></li>
<li><a href="<?php echo "m_category.php?product='packaging'"; ?>">Packaging & Printing</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='shoes'"; ?>">Shoes & Accessories</a></li>
<li><a href="<?php echo "m_category.php?product='sports'"; ?>">Sports & Entertainment</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='textiles'"; ?>">Textiles & Leather Products</a></li>
<li><a href="<?php echo "m_category.php?product='toys'"; ?>">Toys & Hobbies</a></li>
<li class="color"><a href="<?php echo "m_category.php?product='transport'"; ?>">Transportation</a></li>
<li><a href="<?php echo "m_category.php?product='tools'"; ?>">Tools</a></li>
Below is the product display function
Code: Select all
function products(){
require_once ('dbc1.php');
// Number of records to show per page:
$display = 10;
// Determine how many pages there are...
if (isset($_GET['p']) && is_numeric($_GET ['p'])) { // Already been determined.
$pages = $_GET['p'];
} else { // Need to determine.
// Count the number of records:
if (isset($_GET['product'])){
$product = ($_GET['product']);
}
?>
<title>The MarketPlace</title>
<?php
$q = "SELECT COUNT(id) FROM products WHERE category = $product ";
$r = @mysqli_query ($dbc, $q);
$row = @mysqli_fetch_array ($r, MYSQLI_NUM);
$records = $row[0];
// Calculate the number of pages...
if ($records > $display) { // More than 1 page.
$pages = ceil ($records/$display);
} else {
$pages = 1;
}
} // End of p IF.
// Determine where in the database to start returning results...
if (isset($_GET['s']) && is_numeric ($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
// Make the query:
$q = "SELECT * FROM products WHERE category = $product LIMIT $start, $display ";
$r = @mysqli_query ($dbc, $q);
if ($r) {
echo '<div align="center"><table cellspacing="3" cellpadding="5"
width="100%" style="border:solid; border-width:1px; " bgcolor="#CCCCCC"><tr align="center"><td><b>Product</b></td><td> <b>Description</b> </td><td><b>Phone No</b></td><td><b>Price</b></td></tr>
';
$bg = '#eeeeee'; // Set the initial background color.
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); // Switch the background color.
$imgurl = 'uploads/'.$row["image"].'';
echo '<tr bgcolor="' . $bg . '" align="center"><td><b>'.$row['prodname'].'</b><br>';
echo '<a href="display.php?id='.$row['id'].'&prod='.$row['prodname'].'"><img src= '.$imgurl.' width=100 height=80 border=0><br> <font size="-2">Click for more details...</font></a></td>' ;
echo '<td width="150" align="left" >' . $row['proddescr'] . '</td><td align="left">Call Vendor on:<br>'. $row['phone'] . '</td><td align="left">' . $row['price'] . '</td></tr>';
}
echo '</table></div>';
mysqli_free_result ($r);
mysqli_close($dbc);
}
if ($pages > 1) {
// Add some spacing and start a paragraph:
echo '<br /><p>';
// Determine what page the script is on:
$current_page = ($start/$display) + 1;
// If it's not the first page, make a Previous button:
if ($current_page != 1) {
echo '<a href="m_category.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> ';
}
// Make all the numbered pages:
for ($i = 1; $i <= $pages; $i++) {
if ($i != $current_page) {
echo '<a href="m_category.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> ';
} else {
echo $i . ' ';
}
} // End of FOR loop.
// If it's not the last page, make a Next button:
if ($current_page != $pages) {
echo '<a href="m_category.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>';
}
echo '</p>'; // Close the paragraph.
} // End of links section.
}