不知道怎么转载,原文源自PHP100论坛:http://bbs.php100.com/read-htm-tid-598955.html
第一例
<?php
$s_html="<b>文字加粗it1994.cn</b>";
echo $s_html;
?>
第二例
<?php
$s_javascript=<<<start
<script type="text/javascript">
alert("it1994.cn");
</script>
start;
echo $s_javascript;
?>
第三列
<?php
$a="name";
$$a="hello php";
echo $name;
?>
第四例
<?php
$color="";
echo "<ul>";
for($i=1;$i<=10;$i++)
{
if($i%2==0)
{
$color="red";
}else
{
$color="yellow";
}
echo "<li style=‘background:".$color.";width:200px‘>第".$i."行</li></ul>";
}
?>
第五例
index.php页面:
<form action="check.php" method="post">
用户名:<input type="text" name="user" /><br />
密码:<input type="password" name="pass"/><br />
<input type="submit" value="提交"/>
<input type="reset" value="重置"/>
</form>
check.php页面:
<?php
if(isseet($_POST))
{
if($_POST[‘name‘]==‘admin‘ && $_POST[‘pass‘]==‘admin‘)
{
echo"用户登录成功";
}else{
echo"用户登录失败";
}
}
?>
第6列
<?php
echo "index.php<br><br>";
echo "_FILE_:"._FILE_."<br>";
echo "request_uti:".$_SERVER["request_urt"]."<br>";
echo "script_name:".$_SERVER["script_name"]."<br>";
echo "php_self:".$_SERVER["php_self"]."<br>";
echo "script_filename:".$_SERVER["script_filename"]."<br>";
?>
第7列
<?php
$str="0123456789abcdefghijklmnopqrstuvwxyz";
$n=5; //字符长度
$len=strlen($str)-1;
for($i=0;$i<$n;$i++)
{
$s = $s.$str[rand(0,$len)];
}
echo $s."<br/>";
?>
第8列
<?php
$a=‘it1994.cn‘;
echo "直接输出:".$a;
echo "<br/>";
echo "直接输出:".‘$a‘;
echo "<br/>";
echo "直接输出:"."$a";
?>
第9列
index.php页面:
<?php
echo "常见的原子操作";
echo "<a href=‘check.php?action=add‘>执行增加操作</a><br/>";
echo "<a href=‘check.php?action=del‘>执行删除操作</a><br>";
echo "<a href=‘check.php?action=search‘>执行查找操作</a><br>";
echo "<a href=‘check.php?action=update‘>执行更新操作</a><br>";
?>
check.php页面:
<?php
$action=$_GET["action"];
switch($action)
{
case "add";
echo "<script>alert(‘现在可以实现增加功能!‘);</script>";
break;
case "del";
echo "<script>alert(‘现在可以实现删除功能!‘);</script>";
break;
case "search";
echo "<script>alert(‘现在可以实现查找功能!‘);</script>";
break;
case "update";
echo "<script>alert(‘现在可以实现更新功能!‘);</script>";
break;
}
?>
第10列
index.php页面:
<html>
<head><title>it1994.cn</title></head>
<body>
<form action="check.php" method="post">
message<input type="text" name="name" value="123456"/>
<input type="submit" value="提交" />
</form>
</body>
</html>
check.php页面:
<?php
$urlar=parse_url($_SERVER[‘http_referer‘]);
print("<pre>");
print_r($urlar);
print_r($_SERVER[‘http_referer‘]);
if($urlar[‘host‘]!="172.0.0.1")
{
echo "页面失效";
echo "<script>alert(‘链接失效‘);location=‘index.php‘;</secript>";
exit;
}
echo "可以正常访问页面";
?>
第23例
<!--不区分大小写输入的用户登录名-->
<form action="check.php" method="post">
<table width="250px" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#cccccc">
<tbody>
<tr>
<td colspan="2" height="25" bgcolor="#f7f7f7" align="center">
用户登录——不区分大小写
</td>
</tr>
</tbody>
<tr>
<td width="20%" height="25" align="right" bgcolor="#f7f7f7">
用户名:
</td>
<td height="25" bgcolor="#f7f7f7">
<input style="" name="username" type="text" id="username"/>
</td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#f7f7f7">
密码:
</td>
<td height="25" bgcolor="#f7f7f7">
<input type="password" name="userpwd" id="password"/>
</td>
</tr>
<tr align="center">
<td height="25" colspan="2" align="right" bgcolor="#f7f7f7">
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="39%" align="right">
<span style="word-spacing: 0px; margin:0px ; margin-bottom: 0px;" >
<input type="submit" name="login" id="login" value="登录"/>
</span>
</td>
<td width="61%">
<input type="reset" name="reset" id="reset" value="重置"/>
</td>
</tr>
</table>
</form>
第24例
倒计时某些赛事
<?php
header("Content-Type:text/html;charset=utf-8");
$i=time();
$x=strtotime("2015-04-5 00:00:00");;
$d=round(($x-$i)/3600/24);
echo "<b>距离清明节还有:<font color=‘red‘>".$d."</form>天</b>";
?>
第25例
index.php页面:
读取外部文本并分页
function m_substr($str,$start,$length)
{
$str_length=$start=$length;
$tmp_str="";
for($i-0;$i<$str_length;$i++)
{
if(ord(substr($str,$i,1))==0x0a)
{
$tmp_str.=‘<br/>‘;
}
if(ord(substr($str,$i,1))>0x0a)
{
$tmp_str.=substr($str,$i,2);
$i++;
}else
{
$tmp_str.=substr($str,$i,1);
}
}
retun $tmp_str;
}
?>
<body>
<div id="header">
<b>文本文件内容分页显示</b>
</div>
<div id="content">
<div id="show">
<p>
<?php
/*此处省略自定义函数m_substr()具体实现*/
if(isset($_GET[‘page‘]))
{
$page=$_GET[‘page‘];
}else{
$page=1;
}
$counter=file_get_contents("example.txt");
$length=strlen($counter);
$page_count=ceil($length/400);
$str=m_substr($counter,0,($page-1)*400);
$str1=m_substr($counter,0,$page*400);
echo substr($str1,strlen($str),strlen($str1)-strlen($str));
?>
</p>
</div>
<center>
<span>
<?php
echo "当前页:".$page."/".$page_count." ";
echo "<a herf=index.php?page=1>首页</a>";
if($page>1)
{
echo "<a herf=index.php?page=".($page-1).">上一页</a>";
}
if($page<$page_count)
{
echo "<a herf=index.php?page=".($page+1).">下一页</a>";
}
echo "<a herf=index.php?page=".$page_count.">尾页</a>";
?>
</span>
</center>
</div>
<div id="footer"><br />文本分页</div>
</body>
第26例
会员信息分页显示
conn.php页面:
<?php
header("Content-Type:text/html;charset=utf-8");
mysql_connect("localhost","root","") or die("数据库连接有误!");
mysql_select_db("student") or die("数据库选择有误!");
mysql_query("set names ‘utf8‘");
?>
<?php
//user.php页面:
$page=isset($_GET[‘page‘])?$_GET[‘page‘]:1;
$pagesize=5; //显示条数
$sql="select count(*) from student";
$result=mysql_query($sql);
$maxrows=mysql_result($result,0,0);
$maxpage=ceil($maxrows/$pagesize);
if($page>$maxpage)
{
$page=$maxpage;
}
if($page<1)
{
$page=1;
}
$offset=($page-1)*$pagesize;
$sql="select * from student limit{$offset},$pagesize";
$result=mysql_query($sql);
while($rows=mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>{$rows[‘id‘]}</td>";
echo "<td>{$rows[‘username‘]}</td>";
echo "<td>{$rows[‘email‘]}</td>";
echo "<td>".date("Y-m-d H:i:s",$rows[‘datetime‘]+8*3600)."</td>";
echo "</tr>";
}
?>
第27例:
检测用户输入日期的合法性
<form action="index.php" method="poost">
<b>检测用户输入日期的合法性</b>
用户名:<input type="text" name="username" value=""/><br />
生日日期:<input type="text" name="userdate" value="" size="18"/><br />
<input type="submit" value="检测"/>
<input type="reset" value="重置"/>
</form>
<?php
if(!empty($_POST[‘username‘]))
{
$arr=explode("-",$_POST[‘userdate‘]);
if(checkdate($arr[1],$arr[2],$arr[0]))
{
echo "<script>alert(‘日期".$_POST[‘userdate‘]."格式正确‘)</script>";
}else{
echo "<script>alert(‘日期".$_POST[‘userdate‘]."格式不对‘)</script>";
}
}
?>
第28例
延迟php脚本的执行时间
<?php
header("Content-Type:text/html;charset=utf-8");
echo "脚本载入时间:".date(‘Y-m-d H:i:s‘);
sleep(5); //脚本等待5秒后执行
echo "<br/><br/>";
echo "执行完毕时间:".date(‘Y-m-d H:i:s‘);
?>
第29例
使用php动态创建嵌套文件夹
<?php
header("Content-Type:text/html;charset=utf-8");
function createfolder($path)
{
if(!file_exists($path))
{
createfolder(dirname($path));
mkdir($path,0777);
}
}
createfolder("aa/bb/cc");//模拟测试
?>
第30例
用户成绩查询
<?php
header("Content-Type:text/html;charset=utf-8");
?>
<form action="index.php" method="post" >
<b>输入分数</b><br />
分数:<input type="text" name="result" value=""/><br />
<input type="submit" value="查询"/>
<input type="reset"/>
</form>
<?php
if(!empty($_POST[‘result‘]))
{
$result=$_POST[‘result‘];
if($result>=80&&$result<=100)
{
echo "<script>alert(‘您的成绩为优秀‘)</script>";
}else if($result>=60&&$result<80)
{
echo "<script>alert(‘您的成绩为合格‘)</script>";
}else
{
echo "<script>alert(‘您的成绩为不合格‘)</script>";
}
}
?>
第31例
用户输入日期查询备忘录
<?php
header("Content-Type:text/html;charset=utf-8");
?>
<form action="index.php" method="post">
<b>输入日期:</b><br />
<input type="text" name="date"/><br />
<input type="submit" value="查询"/>
<input type="reset"/>
</form>
<?php
if(!empty($_POST[‘date‘]))
{
$date=$_POST[‘date‘];
$rc=array(); //数组
$rc[‘5-1‘]=‘查看网站 IT1994.cn‘;
$rc[‘5-2‘]=‘同学聚会‘;
$rc[‘5-3‘]=‘购物‘;
$rc[‘5-4‘]=‘出差‘;
$rc[‘5-5‘]=‘发邮件‘;
foreach($rc as $key=>$value)
{
if($key==$date)
{
echo "<script>alert(‘".$key."日备忘录:".$value."‘)</script>";
}else
{
echo "<script>alert(‘无备忘录‘)</script>";
break;
}
}
}
?>
第32例
隔行换色
<?php
header("Content-Type:text/html;charset=utf-8");
echo "<center><b>隔行换色</b></center>";
$color="";
echo ‘<table border="1" width="200" height="200" align="center" cellspacing="0">‘;
for($i=0;$i<5;$i++)
{
if($i%2==0)
{
$color="red";
}else
{
$color="blue";
}
echo "<tr bgcolor=‘".$color."‘>";//输出行并把颜色赋值给背景
for($j=0;$j<5;$j++)
{
echo "<td>".$j."</td>";
}
echo "</tr>";
}
echo "</table>";
?>
第33例
输出倒序乘法表
<?php
header("Content-type:text/html;charset=utf-8");
for($i=9;$i>=1;$i--)
{
for($j=$i;$j>=1;$j--)
{
echo "$i*$j=".($i*$j)." ";
}
echo "<br/>";
}
?>
第34例
表格计算器
<?php
header("Content-Type:text/html;charset=utf-8");
?>
<form action="index.php" method="post">
结果:<input type="text" name="sum" id="sum" size="15"/><br />
数字1:<input type="text" name="num1" size="10"/><br />
运算符:<select name="sub">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select><br />
数字2<input type="text" name="num2" id="num2" size="10"/><br />
<input type="submit" value="计算"/>
<input type="reset"/>
</form>
<?php
if(!empty($_POST[‘num1‘]))
{
$num1=$_POST[‘num1‘];
$num2=$_POST[‘num2‘];
$sub=$_POST[‘sub‘];
$sum=0;
switch($sub)
{
case "+":
$sum=$num1+$num2;
break;
case "-":
$sum=$num1-$num2;
break;
case "*":
$sum=$num1*$num2;
break;
case "/":
$sum=$num1/$num2;
break;
}
echo "<script>alert(‘计算出结果为:".$sum."‘);</script>";
echo "<script>document.getElementById(‘sum‘).value=‘".$sum."‘</script>";
}
?>
第35例
php动态表格生成器
<style type="text/css">
body{
background:#ccc;
}
</style>
<form action="35.php" method="post">
<b>输入行列生成表格</b><br><br>
输入行:<input type="text" name="cols"><br><br>
输入列:<input type="text" name="rows"><br><br>
<input type="submit" value="生成表格">
<input type="reset" value="重置行列">
</form>
<?php
header("Content-Type:text/html;charset=utf-8");
if(!empty($_POST[‘cols‘])){
echo"<center><b>用户动态输出表格.行".$_POST[‘cols‘].",列".$_POST[‘rows‘]."</b></center>";
$color="";
echo "<table border=‘1‘ width=‘200px‘ height=‘200px‘ align=‘center‘ cellspacing=‘0‘>";
for($i = 0 ; $i < $_POST[‘cols‘] ; $i++){
if($i%2==0){
$color="red";
}else{
$color="blue";
}
echo "<tr bgcolor=‘".$color."‘>";
for($j = 0 ;$j < $_POST[‘rows‘] ; $j++){
echo "<td>".$j."</td>";
}
echo "</tr>";
}
echo "</table>";
}
?>
第36例:
使用分支语句加载不同网页主体
<div id="header">
<!--页面导航条-->
<ul>
<li><a href="?id=shop1">基本商品</a></li>
<li><a href="?id=shop2">推荐商品</a></li>
<li><a href="?id=shop3">分类商品</a></li>
</ul>
</div>
<div id="content">
<!--此处动态更改主体内容-->
</div>
<?php
$shop_id=$_GET[‘id‘];
switch($shop_id)
{
case "shop1"://如果ID为shop1
require("shop1.php");
break;
case "shop2":
require("shop2.php");
break;
case "shop3":
require("shop3.php");
break;
default://默认的选择
require("shop1.php");
}
?>
第37例:
php万年历
<?php
header("Content-type:text/html;charset=utf-8");
date_default_timezone_set("Asia/Shanghai");//设置日期时区为中国时区
$today = time();
$year =@$_GET["year"];
$month = @$_GET["month"];
if($year==‘‘) $year = date("Y",$today);
if($month==‘‘) $month = date("m",$today);
if((int)$month==0){$year-=1;$month=12;}
$time = mktime(0,0,0,$month,1,$year);//格式化当前日期
$year = date(‘Y‘,$time);
$month = date(‘m‘,$time);
$days = date(‘t‘,$time);//当前月份一共有几天
$fstdw = date(‘N‘,$time);//当前月份第一天为星期几
echo "<table border=1 width=260 cellspacing=0 cellpadding=0 align=center bgcolor=#cccccc>";
echo "<tr><td colspan=7 class="title">";
$str = "<a href=?year=".($year-1)."&month=".$month.">";
$str .= "«</a> ".$year."年 ";
$str .= "<a href=?year=".($year+1)."&month=".$month.">";
$str .= "»</a> ";
$str .= "<a href=?year=".$year."&month=".($month-1).">";
$str .= "«</a> ".$month."月 ";
$str .= "<a href=?year=".$year."&month=".($month+1).">";
$str .= "» </a>";
echo $str;
echo "</td></tr>";
echo"<tr>";
$str = "<td>一</td>";
$str .= "<td>二</td>";
$str .= "<td>三</td>";
$str .= "<td>四</td>";
$str .= "<td>五</td>";
$str .= "<td>六</td>";
$str .= "<td>七</td>";
echo $str;
echo "</td>";
$rows = ceil(($days + $fstdw-1)/7);
$cd = 1;
for($i=0;$i<$rows;$i++){
echo "<tr>";
for($j=0;$j<7;$j++){
echo "<td>";
if($cd >= $fstdw && $cd<$days+$fstdw){
$oday = $cd-$fstdw+1;
if($oday == date(‘d‘,time())){
echo "<font color=‘red‘><b><u>";
}
echo $oday;
}else{
echo ".";
}
$cd++;
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
?>
第38例:
index.php页面:
<?php
header("Content-Type:text/html;charset=utf-8");
mysql_connect("localhost","root","123456") or die("数据库连接有误!");
mysql_select_db("student") or die("数据库选择有误!");
mysql_query("set names ‘utf8‘");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户管理</title>
<style>
body{text-align:center;}
#header{width:600px;height:50px;margin:10px;background:#E3EFFB;line-height:50px;font-size:20px;}
#main{width:600px;margin:10px;margin:0px auto;}
#main table{widt h:600px;background:#E3EFFB;cellspacing:1px;text-align:center;}
#main table tr{background:white;}
#main table img{border:0px;}
#page{width:600px;height:30px;background:#E3EFFB;line-height:30px;}
</style>
</head>
<body>
<div id="header">网站管理中心--会员列表</div>
<div id="main">
<form name="myForm" action="check.php" method="post">
<table>
<tr>
<th width="100">编号</th>
<th width="150">用户名</th>
<th width="200">邮件地址</th>
<th width="200">注册日期</th>
<th width="50">选择</th>
</tr>
<?php
//定义分页所需要的变量
$page=isset($_GET[‘page‘])?$_GET[‘page‘]:1;//当前页
$pagesize=5; //每页显示的条数
//获取总条数数据
$sql="select count(*) from student";
$result=mysql_query($sql);
$maxrows=mysql_result($result,0,0);
$maxpage=ceil($maxrows/$pagesize);
//到达最后一页判断
if($page>$maxpage){
$page=$maxpage;
}
//到达第一页判断
if($page<1){
$page=1;
}
$offset=($page-1)*$pagesize;
$sql="select * from student limit {$offset},$pagesize";
$result=mysql_query($sql);
while($rows=mysql_fetch_assoc($result)){
echo "<tr>";
echo "<td>{$rows[‘member_id‘]}</td>";
echo "<td>{$rows[‘username‘]}</td>";
echo "<td>{$rows[‘email‘]}</td>";
echo "<td>".date("Y-m-d H:i:s",$rows[‘registertime‘]+8*3600)."</td>";
echo
"<td><input type=‘checkbox‘ value=‘{$rows[‘member_id‘]}‘
name=‘member_id[]‘></td>";
echo "</tr>";
}
?>
</table>
<br/>
<div id="page">
<?php
echo "当前{$page}/{$maxpage}页 共计{$maxrows}条信息 ";
echo "<a href=‘user.php?page=1‘>首页</a> ";
echo "<a href=‘user.php?page=".($page-1)."‘>上一页</a> ";
echo "<a href=‘user.php?page=".($page+1)."‘>下一页</a> ";
echo "<a href=‘user.php?page=".$maxpage."‘>最后一页</a>";
echo " <input type=‘submit‘ value=‘批量删除‘>";
?>
</div>
</form>
</div>
</body>
<html>
check.php页面:
<?php
PRINT("<PRE>");
print_r($_POST);
exit();
header("Content-Type:text/html;charset=utf-8");
mysql_connect("localhost","root","123456") or die("数据库连接有误!");
mysql_select_db("student") or die("数据库选择有误!");
mysql_query("set names ‘utf8‘");
if(!empty($_POST[‘member_id‘])){
$arr=$_POST[‘member_id‘];
$str_key="";
foreach($arr as $key=>$value){
$sql="delete from student where member_id =".$value;
mysql_query($sql);
$str_key.=$value.",";
}
$new_str=substr($str_key,0,strlen($str_key)-1);
echo"<script>alert(‘删除编号为".$new_str."的信息成功!‘);location=‘user.php‘</script>";
}
?>
第39例
php生成不重复随机数
<?php
header("Content-type:text/html;charset=utf-8");
$num=5;//要生产多少个随机数
$start=0;
$end=100;
$connt=0;
while($connt<$num)
{
$a[]=rand($start,$end);//产生随机数
$ary=array_unique($a);//遍历数组$a,如有相同的值则剔除该值
$connt=count($ary);//获取数组长度
}
$str="";
foreach($ary as $key=>$value)
{
$str.=" ".$value;
}
echo "<b>随机输出5个随机数</b><br /><br />";
echo "随机数:<b>".$str."</b><br />";
echo "<b><br><font color=‘red‘>范围0-100且不重复</font><b>";
?>
第40例
输入字母或数字出现图案
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<?php header("content-type:text/html;charset=utf-8");?>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body{
background:#ccc;
font-size:12px;
}
.font{
font-size:150px;
color:#c99c96;
font-family:Webdings; //设定输出的字体为Webdings
}
</style>
</head>
<body>
<b>输出字体图片</b><br><br>
<form action="40.php" method="post">
<b>输入26个任意大小写字母</b><br><br>
<input type="text" value="" name="str">
<p>输入z或者Z结束</p>
<input type="submit" value="输出">
<input type="reset" value="重置">
</form>
<?php
$num=0;
if(!empty($_POST[‘str‘])){
$str=$_POST[‘str‘];
do{
echo"<font class=‘font‘>".$str."</font>";
$num++;
}while($num<2);
}
?>
</body>
</html>
第41例
动态输出网站友情链接
<div id="footer">
<ul>
<?php
for($i=1;$i<=5;$i++){
echo
"<li><a href=\"#\"><img src=\"./images/link".$i.".gif\"
width=\"160\" height=\"70\"></a></li>";
}
?>
</ul>
</div>
第42例
表格基数行变色
<?php
header("content-type:text/html;charset=utf-8");
echo "<center>基数行变色</center>";
echo ‘<table width="200" border="1" align="center">‘;
for($i=0;$i<5;$i++)
{
if($i%2==0)
{
echo "<tr bgcolor=‘red‘><td>".$i."</td></tr>";
}else{
echo "<tr><td>".$i."</td></tr>";
}
}
echo "</table>";
?>
第43例
偶数计算器
<?php
header("content-type:text/html;charset=utf-8");
?>
<b>输入个数返回偶数之和</b>
<form action="43.php" method="post">
数量:<input type="text" name="shu" id="shu"/><br />
<input type="submit" value="计算"/>
<input type="reset"/>
</form>
<?php
if(!empty($_POST[‘shu‘]))
{
$shu=$_POST[‘shu‘];
$sun=$shu*2;
$sum=0;
for($i=1;$i<=$sun;$i++)
{
if($i%2==0)
{
$sum+=$i;
}
}
echo "<script>alert(‘前".$shu."偶数之和为:".$sum."‘)</script>";
}
?>
第44例
数据库链接验证
<style>
body{
background:#ccc;
}
</style>
<?php
header("content-type:text/html;charset=utf-8");
$conn=@mysql_connect("localhost","root","") or die("<b>状态<b>:连接MySQL数据库失败!<br>错误信息:".mysql_error());
if($conn){
echo "<script>alert(‘MySQL连接成功‘);</script>";
$db = mysql_select_db("student",$conn);
if($db == 1){
echo "<script>alert(‘数据库选择成功‘);</script>";
mysql_query("set names gbk");
}else{
echo "<script>alert(‘数据库不存在‘);</script>";
}
}
?>
第45例
细边线表格
<?php
header("content-type:text/html;charset=utf-8")
?>
<style type="text/css">
*{
margin:0px;
padding:0px;
}
body{
background:#fff;
}
table{
width:600px;
margin:0 auto;
background-color: #cccccc;
}
table td{
background-color: #FFFFFF;
font-size:12px;
font-weight:normal;
text-align:center;
line-height:16px;
}
</style>
<center><b>细边线表格</b></center>
<br />
<table border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
选择</td><td>表名</td><td>字段类型</td><td>字
段名称</td><td>更新日期</td><td>创建日期<
/td><td>操作</td>
</tr>
<tr>
<td><input
type="checkbox"></td><td>个人客户</td><td>text&
lt;/td><td>项目</td><td>2012-02-01
17:23:17</td><td>2012-02-01
17:23:17</td><td><a href="#">删除</a> <a
href="#">编辑</a></td>
</tr>
<td><input
type="checkbox"></td><td>企业客户</td><td>text&
lt;/td><td>合作</td><td>2011-09-11
10:21:16</td><td>2011-09-11
10:21:16</td><td><a href="#">删除</a> <a
href="#">编辑</a></td>
</tr>
<td><input
type="checkbox"></td><td>政府客户</td><td>text&
lt;/td><td>外包</td><td>2011-06-21
09:21:06</td><td>2012-06-21
09:21:06</td><td><a href="#">删除</a> <a
href="#">编辑</a></td>
</tr>
<td><input
type="checkbox"></td><td>个人客户</td><td>text&
lt;/td><td>购买</td><td>2011-02-01
17:23:17</td><td>2011-02-01
17:23:17</td><td><a href="#">删除</a> <a
href="#">编辑</a></td>
</tr>
<td><input
type="checkbox"></td><td>个人客户</td><td>text&
lt;/td><td>商家</td><td>2011-02-01
17:23:17</td><td>2010-02-01
17:23:17</td><td><a href="#">删除</a> <a
href="#">编辑</a></td>
</tr>
<td><input
type="checkbox"></td><td>企业客户</td><td>text&
lt;/td><td>网站</td><td>2010-02-01
17:23:17</td><td>2009-02-01
17:23:17</td><td><a href="#">删除</a> <a
href="#">编辑</a></td>
</tr>
<td><input
type="checkbox"></td><td>企业客户</td><td>text&
lt;/td><td>其他</td><td>2011-02-01
17:23:17</td><td>2011-02-01
17:23:17</td><td><a href="#">删除</a> <a
href="#">编辑</a></td>
</tr>
</table>
第46例
php搜索框
<?php
header("content-type:text/html;charset=utf-8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> PHP经典案例搜索框 </title>
<style type="text/css">
*{
margin:0;
padding:0;
}
body{
font-size:12px;
background:#aaa;
}
#search{
width:310px;
height:25px;
margin:50px auto;
padding:3px 8px;
line-height:20px;
color:#000;
background:#ddd;
overflow:hidden;
}
#search label{
float:left;
line-height:25px;
font-weight:800;
color:#c00;
}
#search #insert{
padding:2px 4px;
border:1px solid #06c;
margin-top:1px;
color:#666;
float:left;
margin:0 5px;
width:150px;
height:16px;
}
</style>
</head>
<body>
<div id="search">
<form action="" method="post">
<label>PHP经典案例查询</label>
<input name="chepai" type="text" id="insert" value="输入查询关键字" />
<input name="btn" id="btn" type="button" value="查询" />
</form>
</div>
</body>
</html>
第47例
使用css进行页面布局
<?php
header("content-type:text/html;charset=utf-8");
?>
<head>
<title> it1994.cn </title>
<style type="text/css">
*{
margin:0px;
padding:0px;
}
body{
width:600px;
margin:auto;
color:white;
}
#nav{
background:#cccccc;
height:50px;
}
#header{
background: blue;
height:150px;
}
#sidebar{
background:darkgreen;
height:30px;
}
#content{
background:green;
height:30px;
}
#footer {
background:orange;
height:66px;
}
</style>
</head>
<body>
<div id="page">
<div id="nav">导航条</div>
<div id="header">头部广告区域</div>
<div id="sidebar">滑动区域</div>
<div id="content">主体显示内容</div>
<div id="footer">底部</div>
</div>
</body>
第48例
美化用户注册表格
<?php
header("content-type:text/html;charset=utf-8");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> </title>
<meta http-equiv="Content-type" content="text/html;charset=GB2312">
<style type="text/css">
body {
font-family: Arial, Helvetica, sans-serif;
font-size:12px;color:#666666;background:#fff;
text-align:center;
}
* {
margin:0;
padding:0;
}
a {
color:#1E7ACE;
text-decoration:none;
}
a:hover {
color:#000;
text-decoration:underline;
}
h3{
font-size:14px;
font-weight:bold;
}
pre,p{
color:#1E7ACE;
margin:4px;
}
input,select,textarea{
padding:1px;
margin:2px;
font-size:11px;
}
#myform{
width:450px;
margin:15px auto;
padding:20px;
text-align:left;
border:1px solid #A4CDF2;
}
fieldset{
padding:10px;
margin-top:5px;
border:1px solid #A4CDF2;
background:#fff;
}
fieldset legend{
color:#1E7ACE;
font-weight:bold;
padding:3px 20px 3px 20px;
border:1px solid #A4CDF2;
background:#fff;
}
fieldset label{
float:left;
width:120px;
text-align:right;
padding:4px;
margin:1px;
}
fieldset div{
clear:left;
margin-bottom:2px;
}
.buttom{
padding:1px 10px;
font-size:12px;
border:1px #1E7ACE solid;
background:#D0F0FF;
}
.input{
width:120px;
}
.enter{
text-align:center;
}
.clear{
clear:both;
}
-->
</style>
</head>
<body>
<div id="myform">
<center>
<h3> 创建新用户</h3>
</center>
<form method="post" name="myForm" id="myForm">
<fieldset>
<legend>用户注册</legend>
<div>
<label for="Name">用户名</label>
<input type="text" name="Name" class="input" id="Name" size="20" maxlength="30" />
<font color="red">*</font>(可输入字母数组下划线)<br/>
</div>
<div>
<label for="Email">
email
</label>
<input type="text" name="Email" class="input" id="Email" size="20" maxlength="150" />
<font color="red">*</font><br/>
</div>
<div>
<label for="password">
输入密码
</label>
<input type="password" name="password" class="input" id="password" size="18" maxlength="15" />
<font color="red">*</font>(长度不能超过15个字符)<br/>
</div>
<div>
<label for="confirm_password">
重复密码
</label>
<input type="password" name="confirm_password" class="input"
id="confirm_password" size="18" maxlength="15" />
<font color="red">*</font><br/>
</div>
<div>
<label for="AgreeToTerms">
同意用户服务条款
</label>
<input type="checkbox" name="AgreeToTerms" id="AgreeToTerms" value="1" />
<a href="#" title="您是否同意服务条款">
点此查看用户条款
</a> <font color="red">*</font></div>
<div class="enter">
<input name="create791" type="submit" class="buttom" value="提交" />
<input name="Submit" type="reset" class="buttom" value="重置" />
</div>
</fieldset>
</form>
<br/>
</div>
</body>
</html>
第49例
注册表单击显示
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html>
<head>
<title> it1994.cn </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="author">
<meta name="Keywords" content="cstp">
<meta name="Description" content="no-description">
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
font-size:12px;color:#666666;background:#fff;
text-align:center;
}
* {
margin:0;
padding:0;
}
a {color:#1E7ACE;
text-decoration:none;
}
a:hover {color:#000;
text-decoration:underline;}
h3{
font-size:14px;
font-weight:bold;
}
pre,p{
color:#1E7ACE;
margin:4px
;}
input,select,textarea{
padding:1px;
margin:2px;
font-size:11px;}
.buttom{
padding:1px 10px;
font-size:12px;
border:1px #1E7ACE solid;
background:#D0F0FF;
}
#myform{
width:450px;
margin:15px auto;
padding:20px;
text-align:left;
border:1px solid #A4CDF2;
}
fieldset{
padding:10px;
margin-top:5px;
border:1px solid #A4CDF2;
background:#fff;
}
fieldset legend{
color:#1E7ACE;
font-weight:bold;
padding:3px 20px 3px 20px;
border:1px solid #A4CDF2;
background:#fff;
}
fieldset label{
float:left;
width:120px;
text-align:right;
padding:4px;
margin:1px;
}
fieldset div{
clear:left;
margin-bottom:2px;
}
.input{
width:120px;
}
.enter{
text-align:center;
}
.clear{
clear:both;
}
#close{
position:absolute;
left:440px;
top:30px;
width:50px;
font-size:14px;
}
</style>
<script type="text/javascript">
function show(){
document.getElementById("zhezhao").style.display = "";
document.getElementById("contains").style.display = "";
document.getElementById("zhezhao").style.filter = "Alpha(Opacity=50)";//透明度
}
function hide(){
document.getElementById("zhezhao").style.display = "none";
document.getElementById("contains").style.display = "none";
}
</script>
</head>
<body>
<input onclick="show()" type="button" value="单击显示注册表单" style="font-size:15px;"/>
<div
style="width:100%; background-color:Gray; display:none; height:100%;
position:absolute; left: 0; top: 0;" id="zhezhao">
</div>
<div
style="width: 520px; background-color:#fff; display:none; height:auto;
position:absolute; left: 400px; top: 70px;" id="contains">
<div id="myform">
<center>
<h3>创建新用户</h3>
</center>
<input onclick=‘hide()‘ type=‘button‘ value=‘关闭‘ id="close"/>
<form method="post" name="myForm" id="myForm">
<fieldset>
<legend>用户注册</legend>
<div>
<label for="Name">
用户名
</label>
<input type="text" name="Name" class="input" id="Name" size="20" maxlength="30" />
*(可输入字母数组下划线)<br/>
</div>
<div>
<label for="Email">
email
</label>
<input type="text" name="Email" class="input" id="Email" size="20" maxlength="150" />
*<br/>
</div>
<div>
<label for="password">
输入密码
</label>
<input type="password" name="password" class="input" id="password" size="18" maxlength="15" />
*(长度不能超过15个字符)<br/>
</div>
<div>
<label for="confirm_password">
重复密码
</label>
<input type="password" name="confirm_password" class="input"
id="confirm_password" size="18" maxlength="15" />
*<br/>
</div>
<div>
<label for="AgreeToTerms">
同意用户服务条款
</label>
<input type="checkbox" name="AgreeToTerms" id="AgreeToTerms" value="1" />
<a href="#" title="您是否同意服务条款">点此查看用户条款</a> *
</div>
<div class="enter">
<input name="create791" type="submit" class="buttom" value="提交" />
<input name="Submit" type="reset" class="buttom" value="重置" />
</div>
</fieldset>
</form>
<br/>
</div></div>
<div id="cli">
</div>
</body>
</html>
第50例
人品测试器
<?php
header("content-type:text/html;charset=utf-8");
?>
<center>
<b>人品测试器</b><br />
请输入名字:<input type="text" name="test" id="test" size="10"/>
<input type="submit" value="测试" onclick="test()"/>
<br /><br />显示结果:
<div id="show">
</div>
</center>
<script type="text/javascript">
var arr = new Array();
arr[0] = "人品很好";
arr[1] = "人品一般";
arr[2] = "人品很差";
arr[3] = "极品!!!!(此处省略一万个字)";
arr[4] = "快回火星吧";
function test()
{
var text = document.getElementById(‘test‘).value;
var len = text.length;
var sum = 0;
for(var i = 0;i < len ; i++)
{
sum=sum+text.charCodeAt(i);
}
var yushu = sum%arr.length;
document.getElementById(‘show‘).innerHTML="你的人品得分:"+yushu+"<br>"+arr[yushu];
}
</script>
第51例
图片循环播放
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>简单图片轮播</title>
<style>
p.now{
display:block;
border:1px solid #ccc
}
li.now{
color:#ccc
}
li{
list-style:none;
float:left;
padding:0 10px;
border:1px solid #ccc;
background:#eee;}
#fd{
position:absolute;
left:450px;
top:100px;
height:20px;
width:401px;
background:#ccc}
img{
width:400px;
height:200px;
padding-top:18px;
}
</style>
</head>
<body>
<div id="fd">
<p class="now"><img src="./images/pic1.jpg"></p>
<p style="display:none"><img src="images/pic2.jpg"></p>
<p style="display:none"><img src="images/pic3.jpg"></p>
<p style="display:none"><img src="images/pic4.jpg"></p>
<ul>
<li class="now">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<script>
var tags=$("fd").getElementsByTagName("li");//获取切换按钮节点
var cats=$("fd").getElementsByTagName("p");//获取切换内容节点
var current;//设置当前帧的变量容器
var timer=2000;//设置两秒循环一次
function disAll(){//初始所有标签样式
for(var i=0; i<tags.length; i++){
tags.className="";
cats.className="";
cats.style.display="none";
}
}
function setNow(){//获取当前帧的索引值
for(var i=0; i<tags.length; i++){
if(tags.className=="now"){
current=i;
}
}
}
for(var j=0; j<tags.length; j++)
{//设置手动切换
tags[j].onmouseover=function()
{
clearInterval(h);
disAll();
this.className="now";
setNow();
cats[current].style.display="block";
cats[current].className="now";
}
tags[j].onmouseout=function(){
setNow();
h=setInterval("goNext()",3000);
}
}
function goNext(){//自动切换
setNow();//获取当前帧索引
current+=1;//帧自增1
if(current>=parseInt(tags.length)){//判断:如果当前帧索引值是否大于切换按钮总数,如果大于按钮总数则回到初始状态
current=0;
disAll();
cats[0].style.display="block";
tags[0].className="now";
cats[0].className="now";
}
else{
disAll();
cats[current].style.display="block";
cats[current].className="now";
tags[current].className="now";
}
}
var h=setInterval("goNext()",timer)//开始自动切换
function $(obj){//获取ID节点的简介方法
return document.getElementById(obj)
}
</script>
</body>
</html>
原文:http://www.cnblogs.com/lms520/p/4370166.html