<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[沧海一粟]]></title> 
<link>http://www.dzhope.com/index.php</link> 
<description><![CDATA[Web系统架构与服务器运维,php开发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[沧海一粟]]></copyright>
<item>
<link>http://www.dzhope.com/post//</link>
<title><![CDATA[mysql代码使用技巧备忘]]></title> 
<author>jed &lt;jed521@163.com&gt;</author>
<category><![CDATA[数据库技术]]></category>
<pubDate>Thu, 07 Sep 2006 00:04:39 +0000</pubDate> 
<guid>http://www.dzhope.com/post//</guid> 
<description>
<![CDATA[ 
	 模糊查询<br/><br/>[code]$query =&quot;select * from cdb_posts where message like &#039;%uploadfile=%&#039; order by pid desc&quot;;[/code]<br/><br/>===================================================<br/><br/>限制标题长度<br/><br/>//--------------------限制标题长度－－－－－－－－－－－－//<br/>$len=200;//该数值为字符的长度<br/>//以下用来格式化内容的长度。&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<br/>if(strlen($rows_result[$i][1])&gt;$len)<br/> &nbsp;{<br/>&nbsp;&nbsp;$rows_result[$i][1]=substr($rows_result[$i][1],0,$len);<br/>&nbsp;&nbsp;$rows_result[$i][1]=$rows_result[$i][1].&quot;…&quot;;<br/> &nbsp;}<br/>//--------------------格式化结束。---------------------------------//<br/><br/><br/>==================================================<br/><br/>带分页功能的查询<br/><br/>&lt;?<br/> $hostname=&quot;localhost&quot;;<br/> $username=&quot;foodlt&quot;;<br/> $password=&quot;li6646988&quot;;<br/> $server_link=@mysql_connect($hostname,$username,$password) or die (&quot;连接服务器失败&quot;);<br/> $db_link=@mysql_select_db(&quot;foodlt&quot;,$server_link) or die (&quot;连接数据库失败&quot;);<br/> $query =&quot;select * from cdb_posts where message like &#039;%uploadfile=%&#039; order by pid desc&quot;;<br/> $result=@mysql_query($query);<br/>$i=0;<br/>while($rows=@mysql_fetch_array($result))<br/>{<br/> &nbsp;$rows_result[$i][0]=$rows[&quot;pid&quot;];<br/> &nbsp;$rows_result[$i][1]=$rows[&quot;subject&quot;];<br/> &nbsp;$rows_result[$i][2]=$rows[&quot;fid&quot;];<br/> &nbsp;$rows_result[$i][3]=$rows[&quot;tid&quot;];<br/> $i++;<br/>}<br/> &nbsp; $totalrecords=@mysql_num_rows($result);&nbsp;&nbsp;<br/> &nbsp; &nbsp; if ($page!=&quot;&quot;)<br/> &nbsp; &nbsp; &nbsp; &nbsp; {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $currentpagenum = $page;<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br/> &nbsp; &nbsp; &nbsp;else<br/> &nbsp; &nbsp; &nbsp; &nbsp; {<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$currentpagenum = 0;<br/> &nbsp; &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$recordsperpage=30; &nbsp; // 每页显示记录的个数<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$startshow = $currentpagenum * $recordsperpage; &nbsp;//本页显示的首记录下标=本页码*显示数<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$endshow = $startshow + $recordsperpage; &nbsp; &nbsp; &nbsp;//本页显示的尾记录下标=本页显示的首记录下标+显示数<br/> &nbsp; &nbsp; &nbsp; &nbsp; if ($endshow&gt;$totalrecords)<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$endshow=$totalrecords; &nbsp; //本页尾记录下标&gt;总记录数，则尾记录数取总记录数<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$totalpages=$totalrecords/$recordsperpage;//总页数=总记录数/每页记录数<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($totalpages&gt;(integer)$totalpages)<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $totalpages=(integer)$totalpages+1;//如果总页数为带小数点的，进一取整数<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;else<br/> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$totalpages=(integer)$totalpages; &nbsp;//否则取整数<br/><br/> &nbsp; &nbsp; &nbsp; &nbsp; //定义页眉<br/> &nbsp; &nbsp; &nbsp; &nbsp;$pageinfo=&quot;&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp;if ($currentpagenum&gt;0)<br/> &nbsp; &nbsp; &nbsp; &nbsp;$pageinfo=$pageinfo.&quot;&lt;a href=&#039;gongju.php?page=&quot;.($currentpagenum-1).&quot;&#039;&gt;上一页&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp;if ($currentpagenum&lt;($totalpages-1))<br/> &nbsp; &nbsp; &nbsp; &nbsp;$pageinfo=$pageinfo.&quot;&lt;a href=&#039;gongju.php?page=&quot;.($currentpagenum+1).&quot;&#039;&gt;下一页&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;;<br/> &nbsp; &nbsp; &nbsp; &nbsp;$pageinfo=$pageinfo.&quot;&amp;nbsp;共&quot;.$totalpages.&quot;页&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;第&quot;.($currentpagenum+1).&quot;页&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;.&quot;共&quot;.$totalrecords.&quot;个记录&quot;.&quot;&amp;nbsp;&amp;nbsp;&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;for($i=$startshow;$i&lt;$endshow;$i++)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br/><br/><br/>?&gt;<br/><br/>//循环显示的查询内容<br/><br/>&lt;? }<br/>?&gt;<br/><br/><br/>*************************************************************<br/>strpos()的用法<br/><br/>&nbsp;&nbsp;$body= &quot;&lt;EMBED src=sound/gm37.rm width=200 height=50&quot;;<br/>&nbsp;&nbsp;$a = strpos($body, &quot;=&quot;);//查找最先出现＝的地方<br/>&nbsp;&nbsp;$b = strpos($body, &quot;width&quot;);//找到最先出现width的地方<br/>&nbsp;&nbsp;$filename=substr($body,$d+1,$b-$d-1);//截取sound/gm37.rm<br/>&nbsp;&nbsp;echo $filename;<br/><br/>strpos查找最先出现字符的地方<br/><br/><br/>Tags - <a href="http://www.dzhope.com/tags/%25E5%25A4%2587%25E5%25BF%2598/" rel="tag">备忘</a> , <a href="http://www.dzhope.com/tags/mysql/" rel="tag">mysql</a>
]]>
</description>
</item><item>
<link>http://www.dzhope.com/post//#blogcomment</link>
<title><![CDATA[[评论] mysql代码使用技巧备忘]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.dzhope.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>