<?php

include("inc_dbconn.php");
$cat_id $HTTP_GET_VARS["cat_id"];
$rowOffset $HTTP_GET_VARS["offset"];

// is the auction officially open yet?
$auction_on 1;

// number of items per page
define(ROWS10);

?>

some html

<?

// do db connect

$connection mysql_connect($server,$username,$password);
mysql_select_db($dbname$connection) or die ("Database not available");

// do query to get items from db

$query "select item_id, cat_id, item_name, donated_by, valued_at, minimum_bid, item_desc, image_path, bid, name from items where cat_id='$cat_id' order by valued_at desc";
$result mysql_query($query) or die ("Query Failed");

?>

more html

<?

// do display of items in category

$rowsFound mysql_num_rows($result);

// the previous page begins at current offset LESS number of items per page
$previousOffset $rowOffset ROWS;

// the next page begins at the current offset PLUS number of items per page
$nextOffset $rowOffset ROWS;

// seek to current offset
mysql_data_seek($result$rowOffset);

// fetch one page of results or less if on last page

for ($rowCounter 0; (($rowCounter ROWS) && ($row mysql_fetch_array($result))); $rowCounter++) {
    
$row[2]=urldecode($row[2]);
    
$row[2]=stripslashes($row[2]);
    
$row[6]=urldecode($row[6]);
    
$row[6]=stripslashes($row[6]);
    
$row[3]=str_replace("\""""$row[3]);
    
$row[2]=str_replace("\""""$row[2]);
    
$row[6]=str_replace("\""""$row[6]);
    
$item_id=$row[0];

print 
"<!-- item table -->";
print 
"<table>";
print 
"<tr>";
print 
"<td class='titlecell' width='70%'>$row[2]</td>";
print 
"<td class='itemnumbercell' width='30%'>Item #: $row[0]</td>";
print 
"</tr>";
print 
"<tr>";

if(
$row[8]=="") { $row[8]="0"; }
if(
$row[9]=="") { $row[9]="-"; }


print 
"<td class='datacell' valign='top'><br>Current bid: <b>\$$row[8]</b><br>";
print 
"Current high bidder: <b>$row[9]</b><br><br>";
print 
"Generously donated by: <br>$row[3]<br>";
print 
"Valued at: \$$row[4]";
print 
"<br>";
print 
"Minimum opening bid: \$$row[5]";
print 
"<br>";
print 
"<br>";
print 
"$row[6]";
print 
"<br><br>";
print 
"</td>";
print 
"<td class='imagecell' align='center' valign='top'><br>";
print 
"<img src='$row[7]' width='100' height='100'><br><br>";
print 
"<form action='input.php' method='POST'>";
print 
"<input type='hidden' name='item_name' value='$row[2]'>";
print 
"<input type='hidden' name='item_id' value='$row[0]'>";
print 
"<input type='hidden' name='current_bid' value='$row[8]'>";
print 
"<input type='hidden' name='opening_bid' value='$row[5]'>";
if (
$auction_on==1) {
print 
"<input type='image' src='img/en_button_bidnow.gif' border='0'>";
}
print 
"</form>";
print 
"</td>";
print 
"</tr>";
print 
"</table>";
print 
"<!-- next item -->";
print 
"<p>";
}

// show the row numbers that are being viewed
echo "Showing " . ($rowOffset 1) . "-" . ($rowCounter $rowOffset) . " of ";
echo 
"$rowsFound items in this category<br>";

// are there any previous pages
if ($rowOffset 0) {
    print 
"<a href='./category.php?cat_id=$cat_id&offset=$previousOffset'><< Previous</a>";
print 
"&nbsp;&nbsp;&nbsp;";
}

// are there any next pages
if (($row != false) && ($rowsFound $nextOffset)) {
    print 
"<a href='./category.php?cat_id=$cat_id&offset=$nextOffset'>Next >></a>";
}

?>

                        
closing html