001.
<?
002.
session_start();
003.
?>
006.
<head>
007.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
008.
<title>Untitled Document</title>
009.
</head>
010.
011.
<body>
012.
<?
013.
014.
include
(
"connect.php"
);
015.
016.
$Per_Page
= 10;
017.
018.
$Page
=
$_GET
[
"Page"
];
019.
if
(!
$_GET
[
"Page"
])
020.
{
021.
$Page
=1;
022.
}
023.
024.
$Prev_Page
=
$Page
-1;
025.
$Next_Page
=
$Page
+1;
026.
027.
$Page_Start
= ((
$Per_Page
*
$Page
)-
$Per_Page
);
028.
if
(
$Num_Rows
<=
$Per_Page
)
029.
{
030.
$Num_Pages
=1;
031.
}
032.
else
if
((
$Num_Rows
%
$Per_Page
)==0)
033.
{
034.
035.
036.
037.
038.
$Num_Pages
=(
$Num_Rows
/
$Per_Page
) ;
039.
}
040.
else
041.
{
042.
$Num_Pages
=(
$Num_Rows
/
$Per_Page
)+1;
043.
$Num_Pages
= (int)
$Num_Pages
;
044.
}
045.
046.
047.
048.
049.
050.
051.
052.
$sql
= "SELECT SQL_CALC_FOUND_ROWS *,
053.
DATE_FORMAT(end_date,
'%d/%m/%Y'
) AS ndate
054.
FROM auction
055.
WHERE date_end > NOW()
056.
ORDER BY auc_id DESC
057.
LIMIT
$Page_Start
,
$Per_Page
";
058.
059.
$result
= mysql_query(
$sql
)
or
die
(mysql_error().
":<br />"
.
$sql_select
) ;
060.
061.
062.
063.
064.
065.
066.
067.
068.
echo
"<table align=center>
069.
<tr bgcolor=lavender>
070.
<th width=50>รูป</th>
071.
<th width=250>ชื่อสินค้า</th>
072.
<th width=100>ราคาปัจจุบัน</th>
073.
<th width=100>วันปิดประมูล</th>
074.
</tr>";
075.
while
(
$date
= mysql_fetch_array(
$result
)){
076.
$id
=
$date
[
'auc_id'
];
077.
078.
079.
080.
$sql
=
"SELECT MAX(offer) FROM bids WHERE auc_id = $id"
;
081.
$r
= mysql_query(
$sql
);
082.
$name_price
= mysql_result (
$r
, 0, 0);
083.
084.
085.
086.
if
(
empty
(
$cur_price
)){
087.
$name_price
=
$date
[
'start_price'
];
088.
}
089.
echo
"<tr valign=top>
090.
<td><img width=30 src=pic_name.php?auc_id=
$id
/></td>
091.
<td><a href=\
"name_price.php?auc_id=$id\"
>
092.
<td align=center>
$name_price
</td>
093.
<td align=center>{
$data
[
'ndate'
]}</td>
094.
</tr>";
095.
}
096.
echo
"<tr><td colspan=4 align=center>"
;
097.
098.
echo
"<?=$Num_Pages;?> หน้า : </body></html>"
;
099.
if
(
$Prev_Page
)
100.
{
101.
echo
" <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> "
;
102.
}
103.
104.
for
(
$i
=1;
$i
<=
$Num_Pages
;
$i
++){
if
(
$i
!=
$Page
)
105.
{
106.
echo
"[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"
;
107.
}
else
108.
{
109.
echo
"<b> $i </b>"
;
110.
}
111.
}
112.
if
(
$Page
!=
$Num_Pages
)
113.
{
114.
echo
" <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> "
;
115.
}
116.
echo
"</td></tr></table>"
;
117.
118.
?>
119.
120.
</body>
121.
</html>