先看一个php与mysql数据库的无限分类
建立数据库 :
id,fid,fname(id和fid都必需是数字类型而且fid的默认值一定要设成0;
先看一个php与mysql数据库的无限分类
建立数据库 :
id,fid,fname(id和fid都必需是数字类型而且fid的默认值一定要设成0;
方法一:
用serialize写入,再用unserialize输出
<?php
/**
* PHP获取一组随机数字不重复
*/
$a = microtime();
function createRandID($m){
// 产生一个从1到$m的数组
$arr = range(1,$m);
// 打乱数组
shuffle ($arr);
// 取前十个
for($i=0;$i<=10;$i++){
// 赋值给新数组$n
$n[] = $arr[$i];
}
// 返回这组数字
return implode($n,',');
}
echo createRandID(700000);
echo '<br />';
echo $a - microtime();
?>
1,不做总长度判断,长度判断可以自己加上;
2,支持.net.cn,.com.cn这样的域名后缀;
se.php
<?php
$city = $_GET['city'];
$data = createXml($city);
$xml = simplexml_load_string($data);
header("Content-type: text/xml");
echo $xml->asXML();
// 生成XML数据
function createXml($city)
{
// Google 天气API
$weather = simplexml_load_file("http://www.google.com/ig/api?weather={$city}");
if(isset($weather->weather->forecast_conditions))
{
$low = f2c($weather->weather->forecast_conditions->low['data']);
$high = f2c($weather->weather->forecast_conditions->high['data']);
return "<weather>n<city>{$city}</city>n<low>{$low}</low>n<high>{$high}</high></weather>n";
}
else
{
return "<weather>n</weather>n";
}
}
// 华氏度转摄氏度
function f2c($fahrenhite)
{
return floor(($fahrenhite - 32) / 1.8);
}
<?
//设置PHPExcel类库的include path
set_include_path('.'. PATH_SEPARATOR .
'D:ZealPHP_LIBS' . PATH_SEPARATOR .
get_include_path());
功能简单,直接上代码。
<a href='shortcuts.php'>火星时代IT开发</a>
办法一、按字数控制进行分页
按字数分页办法简单易用,但效果不好。
1,php excelreader操作excel的php类,生成,读取excel等。功能很强大。
下载地址:http://sourceforge.net/projects/phpexcelreader/
注意:__autoload() 内的错误不能被 try-catch 捕获。
function __autoload($class_name){
写一个函数,将数据
处理后返回如下:
河北
-保定
--涿州
北京
-海淀
--中关村