蓝色魔法

蓝色的魔法,永恒的世界.

关于MySQL中limit的一些变化

二月13

今天终于把分页问题解决了,但是关于limit的变化还是非常郁闷的.

事情是这样D: 我记得以前用select语句时候加上limit 0,3的意思是显示第0条到第3条记录,也就是会显示0,1,2,3一共四条几录.  而现在用同样的语句只显示3条,而却不单单3条那么简单,如果改成1,3,还是显示3条只不过是1开始后的3条.

无限迷茫了1个星期,今天终于灵光一闪原来limit后的数字的意义改变了. 新的limit后2个数字意思是 “从第几条开始”,”显示几条”. 也就是说,如果是0,3,那么新的litmit的意思是,从第0条记录开始,显示3条记录, 同样的1,3的意思是从第1条记录开始显示3条(这里的第一条记录实际指的是第二条,因为从0数起.)

对于新的limit我的感觉是确实变方便了,当然如果不知道怎么运作的会和我一样非常迷茫和郁闷, 但是了解了以后其实这个改动是非常方便的. 最明显的就是做分页的时候, 以前还要用公式去计算当前页的起始号码然后再去算终结号码. 现在么很简单, 原来起始位置用当前页-1,原来的终结位置直接填上每页显示条数就可以了,搞定.

过几天整理一下自己写的分页然后发上来分享吧.

posted under PHP | No Comments »

自己做的一个漂亮的搜索框.

二月13

现在网页美观可以说是每个站长都要注重的东西, 普通文本+按钮式的搜索框已经无法满足网页整体的美观. 所以制作一些更漂亮的搜索框则显得尤为重要. 本人也做了一个搜索框给大家分享,走的是比较简洁的路线希望大家喜欢.

这里是最终样式:  search_bar

这个搜索框主要用了div+css没什么难度

也稍微提示一下制作此类关键点:

  • 要把文本框变透明, 要在css里设置4条边框为无,不然默认情况下文本框边框为实线,然后把背景设为transparent (透明,如果有必要的话.)
  • 提交按钮比较关键,为了不破坏整个搜索框的美观, 用原来的按钮式提交是不行D, 这里方法就是把Search做成图片形式的提交方法如下:  <input type=”image” src=”图片地址”>. 我也百度过发现网上很多人用的是JS+图片的方法来提交(图片img标签里加入onclick属性), 这样比较复杂但是如果图片要和表单离开很远这个方法就比较好,不用把真个网页都放到一个表单里, 这里就不提供怎么做了, “百度一下tm”吧.

图片素材:  1.search_bar 2.search_bar_send

完整的HTML代码:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />

<title>ljzlxj</title>

<style>

.search_bar {

background-color: transparent;

border-top-style: none;

border-right-style: none;

border-bottom-style: none;

border-left-style: none;

height: 25px;

width: 180px;

background-image: url(images/search_bar.jpg);

background-repeat: no-repeat;

background-position: left center;

position: relative;

}

.search_textfield {

border-top-style: none;

border-right-style: none;

border-bottom-style: none;

border-left-style: none;

background-color: transparent;

width: 110px;

}

.search_bar_Send {

background-color: transparent;

border-top-style: none;

border-right-style: none;

border-bottom-style: none;

border-left-style: none;

}

</style>

<body>

<form action=”#” method=”get”>

<div class=”search_bar”>

<table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>

<tr>

<td align=”right”>

<input class=”search_textfield” name=”search_textfield” type=”text” id=”textfield” value=”Search” maxlength=”50″ />

</td>

<td width=”47″ align=”left” valign=”middle” ><input type=”image” src=”images/search_bar_send.jpg” style=”height:25;width:45;” name=”search_send”/></td>

</tr>

</table>

</div>

</form>

</body>

</html>

还有一些需要完善的地方,比如鼠标经过自动选择等等.

欢迎转帖不过请保留原帖链接谢谢.

posted under HTML | No Comments »

PHP字符串剪辑substr()的一些小技巧.

二月13

在PHP中要剪辑一段字符串有很多方法,最简单的就是substr()了

在手册里的用法为:

substr

(PHP 3, PHP 4, PHP 5)   

substr – Return part of a string

   

Description

string substr ( string string, int start [, int length] )

substr() returns the portion of string specified by the start and length parameters.

If start is non-negative, the returned string will start at the start‘th position in string, counting from zero. For instance, in the string ‘abcdef‘, the character at position 0 is ‘a‘, the character at position 2 is ‘c‘, and so forth.

 

很简单substr(“字符串内容(可以是一个变量)”,开始,结束)

这里说一下开始是从0开始,也就是如果字符串是12345,开始写0结束写4那么就输出12345,如果从1开始就是2345.

这里一个技巧, 如果你要删除最后一个或几个字符怎么办呢? 比较”笨”的做法是算出这个字符串一共多少个字然后在用0到总字符数-1. 这里有更快更简单的方法.substr(‘12345a’,0,-1)这样输出的是12345,对了就是那么简单.  -1等于总字符减去1. 同样的如果要删除后4个字符那么用0到-4就可以了.

posted under PHP | No Comments »
Newer Entries »