桌面中心(四)数据显示_php基础

来源:奥索网

桌面中心(四)数据显示
作者:elong

最后一步就是显示了。
下面这个程序要通过参数来调用。
比如php.php?jpg=jpg
后面的jpg是表格名。记住一定要的呀,不然就不能运行了,会显示程序出错。
大家可以把下面这个程序改一下。这样就可以更加美观了。

以下是源程序:
<html>
<head><title>显示</title>
</head>
<body>
<?
mysql_connect("localhost","用户名","密码") or die("无法联接数据库!");
$query="SELECT id,url,mess,fromx,url1,mess1,fromx1,url2,mess2,fromx2,url3,mess3,fromx3 from $jpg " ;
$result=mysql_db_query("elong",$query); //执行查询
$num=mysql_numrows($result);
$page=round($page);
$pagesize=4;
if ($page==0){
$page=1;}
else{
$page=$page;}
$pagecount=($num)/$pagesize;
$pagecount=ceil($pagecount);
?>
<?if ($page!=1 and $num!=0){
printf("<a href="%s?page=%s&jpg=$jpg">首页</a>",$PHP_SELF,1);
printf("<a href="%s?page=%s&jpg=$jpg"> 前页</a>",$PHP_SELF,$page-1);
}else{
?> 首页 前页 <?
}
?>
</font>  
<?if ($page!=$pagecount and $num!=0){
printf("<a href="%s?page=%s&jpg=$jpg"> 后页</a>",$PHP_SELF,$page+1);
printf("<a href="%s?page=%s&jpg=$jpg"> 尾页</a>",$PHP_SELF,$pagecount);
}else{?> 后页 尾页 <?}?>页次:<strong><?echo $page?></strong>/<strong><?echo $pagecount?></strong>页
</span></td>
<?
if ($num<>0){
$pp=0;
for($ipage=0;$ipage<$pagesize;$ipage++){
$i=($page-1)*$pagesize+$ipage;
if($i < $num) {
$id=mysql_result($result,$i,"id");
$url=mysql_result($result,$i,"url");
$mess=mysql_result($result,$i,"mess");
$fromx=mysql_result($result,$i,"fromx");
$url1=mysql_result($result,$i,"url1");
$mess1=mysql_result($result,$i,"mess1");
$fromx1=mysql_result($result,$i,"fromx1");
$url2=mysql_result($result,$i,"url2");
$mess2=mysql_result($result,$i,"mess2");
$fromx2=mysql_result($result,$i,"fromx2");
$url3=mysql_result($result,$i,"url3");
$mess3=mysql_result($result,$i,"mess3");
$fromx3=mysql_result($result,$i,"fromx3");
$pp=$pp+1;
       ?>
<table width="668" border="2" cellspacing="0" cellpadding="0" align="center" bordercolor="#FFFFFF">
<tr>
<td width="167" height="127"> <a href="<?echo $url?>" target="_blank"><IMG border=0 src="<?echo $mess?>" width="160" height="120" border="4"></td>
<td width="167" height="127"><a href="<?echo $url1?>" target="_blank"><IMG border=0 src="<?echo $mess1?>" width="160" height="120" border="4"></td>
<td width="167" height="127"><a href="<?echo $url2?>" target="_blank"><IMG border=0 src="<?echo $mess2?>" width="160" height="120" border="4"></td>
<td width="167" height="127"><a href="<?echo $url3?>" target="_blank"><IMG border=0 src="<?echo $mess3?>" width="160" height="120" border="4"></td>
</tr>
</table>

<?
}
}
}
?>

  <td nowrap align=center> <span class=smallFont><span class=titleFont>分页</span>
     <font color=darkgray> <?if ($page!=1 and $num!=0){
printf("<a href="%s?page=%s&jpg=$jpg">首页</a>",$PHP_SELF,1);
printf("<a href="%s?page=%s&jpg=$jpg"> 前页</a>",$PHP_SELF,$page-1);
}else{
?> 首页 前页 <?}?> </font> <?if ($page!=$pagecount and $num!=0){
printf("<a href="%s?page=%s&jpg=$jpg"> 后页</a>",$PHP_SELF,$page+1);
printf("<a href="%s?page=%s&jpg=$jpg"> 尾页</a>",$PHP_SELF,$pagecount);
}else{?> 后页 尾页 <?}?>页次:<strong><?echo $page?></strong>/<strong><?echo $pagecount?></strong>页
</span></td>

 </TABLE></DIV></CENTER>
</BODY></HTML>

时间: 2024-09-20 01:06:14

桌面中心(四)数据显示_php基础的相关文章

php桌面中心(四) 数据显示_php实例

最后一步就是显示了.  下面这个程序要通过参数来调用.  比如php.php?jpg=jpg  后面的jpg是表格名.记住一定要的呀,不然就不能运行了,会显示程序出错.  大家可以把下面这个程序改一下.这样就可以更加美观了.  以下是源程序:  <html>  <head><title>显示</title>  </head>  <body>  <?  mysql_connect("localhost",&qu

桌面中心(四)数据显示

最后一步就是显示了. 下面这个程序要通过参数来调用. 比如php.php?jpg=jpg 后面的jpg是表格名.记住一定要的呀,不然就不能运行了,会显示程序出错. 大家可以把下面这个程序改一下.这样就可以更加美观了. 以下是源程序: <html> <head><title>显示</title> </head> <body> <? mysql_connect("localhost","用户名"

PHP新手上路(十四)_php基础

其他杂项 13.1 生成图像   PHP可以操作处理图像.如果你已经安装了GD库,你甚至可以利用PHP生成图像. <? Header("Content-type: image/gif"); $string=implode($argv," "); $im = imagecreatefromgif("images/button1.gif"); $orange = ImageColorAllocate($im, 220, 210, 60); $p

PHP 和 MySQL 基础教程(四)_php基础

MySQL 中的 SQL 对于 MySQL ,第一件你必须牢记的是它的每一行命令都是用分号 (;) 作为结束的,但--没有完全绝对的事,在这儿也是一样. 前面我曾经讲到,当一行 MySQL 被插入在 PHP 代码中时,最好把后面的分号省略掉,例如: mysql_query ("INSERT INTO tablename (first_name, last_name) VALUES ('$first_name', '$last_name') "); 这是因为 PHP 也是以分号作为一行的

十天学会php之第四天_php基础

  学习目的:学会连接数据库 PHP简直就是一个函数库,丰富的函数使PHP的某些地方相当简单.建议大家down一本PHP的函数手册,总用的到. 我这里就简单说一下连接MYSQL数据库. 1.mysql_connect 打开 MySQL 服务器连接. 语法: int mysql_connect(string [hostname] [:port], string [username], string [password]); 返回值: 整数 本函数建立与 MySQL 服务器的连接.其中所有的参数都可

模仿OSO的论坛(四)_php基础

reply.php(用来回复主题) <HTML><HEAD><TITLE>疑难问题</TITLE> <LINK href="mypic/style.css" rel=STYLESHEET type=text/css></HEAD> <?php if (!$cook_user) {echo "<script language='javascript'>";  echo "

挑战最棒的留言本的源码(四)_php基础

config.php文件 <?php  // 你的用户名和密码,以及数据库名,和表名,在这里一次定义!!! // 由于怕用户名和密码被别人通过浏览器看到,所以用了php的扩展名,这样通过浏览就看不到了!!!.      $username='your_name';          //用户名      $password='your_password';          //密码      $hostname='localhost';              //主机名,一般都为local

桌面中心(一)创建数据库_php基础

来源:奥索网 桌面中心(一)创建数据库 作者:elong 这是小弟第一次写文章.不知道能不能发布呀..我把程序写出来是想要大家参考一下.如果有哪位高手能改出更好的程序, 请别忘了和我说一声呀. :P 源程序的演示页面在elong.oso.com.cn/desk/ 第一步创建数据库: 我们就以OSO的数据库为列说明一下. 先登入数据库.然后在点自己的的数据库名,就在左边. 在输入命令那儿输入以下命令. CREATE TABLE jpg ( id int(8) NOT NULL auto_incre

桌面中心(三)修改数据库_php基础

来源:奥索网 桌面中心(三)修改数据库作者:elong 下面这个程序在你输入id后就把那个id的数据列出来.然后你就可以修改后写入了. <html> <body> <h1>数据库的数据更新</h1> <? if(isset($id)) { if(!mysql_connect("localhost","用户名","密码")) {echo"无法联接数据库"; exit(); }