当前位置: 首页 > 图文教程 > 网络编程 > PHP > 影响PHP+MYSQL执行速度的写法对比
[code]<?php
include_once("../db.php");
if($_GET[x2]==0 and $_GET[x1]==0)
{
$t=" s1='' ";
}else
{
if($_GET[x2]!=0)
{
$t=" x2='$_GET[x2]' ";
}else
if($_GET[x1]!=0)
{
$t=" x1='$_GET[x1]' and x2=0 ";
}
}
$query = "select count(*) from ask_member where $t ";
$result2 = mysql_db_query($DataBase, $query);
$r3 = mysql_fetch_array($result2);
$amount=$r3[0];
$page_size=5;
if($amount%$page_size==0 and $amount>0)
{
$pagecount=($amount/$page_size);
}else
{
$pagecount=intval($amount/$page_size)+1;
}
if($_GET
==0)
{$_GET
=1;}
if($_GET
>$pagecount)
{$_GET
=$pagecount;}
$page=$_GET
;
$a=($_GET
-1)*$page_size;
$query = "select tid,truename,school,study,city,logo,year,month,x1,x2 from ask_member where $t order by logo desc, logintime desc limit $a,$page_size ";
$result = mysql_db_query($DataBase, $query);
while($r2[] = mysql_fetch_array($result))
{
}
foreach($r2 as $rr2)
{
$query = "select name,tid from ask_school where tid='$rr2[x2]' ";
$result2 = mysql_db_query($DataBase, $query);
$r5[] = mysql_fetch_array($result2);
}
$n=count($r2)-1;
?>
<?php
for($i=0;$i<$n;$i++)
{
?>
<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#57ACF2">
<tr>
<td align="center" bgcolor="#FFFFFF">
<table width="690" border="0" cellspacing="0" cellpadding="0">
<tr valign="middle">
<td width="80"><img
src="../ask/center/memberlogo/<?php if($r2[$i][logo]!=''){echo $r2[$i][logo];}else if ($r2[$i][sex]=='女'){echo "/upload/tech/20091012/20091012013937_605ff764c617d3cd28dbbdd72be8f9a2.gif";}else{echo "/upload/tech/20091012/20091012013937_08419be897405321542838d77f855226.gif";} ?>" border=0 width="100" height="127" onload="javascript:DrawImage(this,100,127)"></td>
<td width="430"><strong><?php echo $r2[$i][truename]; ?> - <font color="#85B000">信息 :)</font></strong><br>
字段一:<a href="#" class="blue"><?php echo $r5[$i][name]==''?'内容':$r5[$i][name]; ?></a> <br>
字段二:<a href="#" class="blue"><?php echo $r2[$i][study]; ?></a><br>
字段三:<a href="#" class="blue"><?php echo $r2[$i][year]; ?><?php echo $r2[$i][month]; ?></a><br>
浏览:<a href="#" class="blue">一</a> <font color="#0E6FBE">|</font>
<a href="#" class="blue">二</a> <font color="#0E6FBE">|</font>
<a href="#" class="blue">三</a> </td>
<td width="180" align="right"><table width="110" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="20" align="center" bgcolor="#eeeeee"><a href="hello.php?tid=<?php echo $r2[$i][tid]; ?>">打个招呼</a></td>
</tr>
</table>
<table width="110" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="3"></td>
</tr>
</table>
<table width="110" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="20" align="center" bgcolor="#eeeeee"><a href="sendmessagelook.php?tid=<?php echo $r2[$i][tid]; ?>">其它操作</a></td>
</tr>
</table>
<table width="110" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="3"></td>
</tr>
</table>
<table width="110" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td height="20" align="center" bgcolor="#eeeeee"><a href="addfriend.php?tid=<?php echo $r2[$i][tid]; ?>">操作二</a></td>
</tr>
</table>
<table width="110" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="3"></td>
</tr>
</table>
<table width="110" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="3"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="10"></td>
</tr>
</table>
<?php
}
?> [/code]
问题一:为什么要用
评论 (0) All