急,请帮我把程序加个分页,非数据库
请帮我把程序加个分页处理,需要上一页,下一页,自己输入点GO,列表选择
显示在Table的上边,谢谢,我用JSP会分页,不熟悉PHP,试了半天头都大了,(JAVA写多了用PHP真不习惯,基本的东西都有点问题)请高手帮我写写
程序说明:建立目录data/ 此程序自动读取里面的文件
如果写成外部调用更好
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>mp3</title>
<?php
$mp3_list = array();
$mp3_dir = dir('data');
while (false !== ($mp3_file = $mp3_dir->read()))
{
if($mp3_file != '.' && $mp3_file != '..')
{
$mp3_list[] = $mp3_file;
}
}
$mp3_dir->close();
?>
</head>
<body>
<table width="100%" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF">
<tr bgcolor="#C6DAFB">
<td>歌曲名称</td>
<td>试听</td>
<td>下载</td>
</tr>
<?php foreach($mp3_list as $num => $mp3_file){ ?>
<tr bgcolor="#D7E8CC">
<td><?php print $mp3_file; ?></td>
<td><a href="?play=<?php print $num; ?>">试听</a></td>
<td><a href="mp3/<?php print $mp3_file; ?>" target="_blank">下载</a></td>
</tr>
<?php
if(isset($_GET['play']) && $num == $_GET['play'])
{
$play = $mp3_file;
}
} ?>
</table>
<div>
<?php
if($play)
{
print '<embed src="data/'.$play.'" width="600" height="45"></embed>';
}
?>
</div>
</body>
</html>