PHP多维数组
/***************************by
garcon1986********************************/
一个三维数组的显示,保存以备以后使用。
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$conn = mysql_connect("localhost","charles","charles");
mysql_select_db("crm1204", $conn);
//为了更好的显示for better display
function dump($vars, $label = null, $return = false) {
if (ini_get('html_errors')) {
$content = "<pre>\n";
if ($label !== null && $label !== '') {
$content .= "<b>{$label} :</b>\n";
}
$content .= htmlspecialchars(print_r($vars, true));
$content .= "\n</pre>\n";
}
else {
$content = "\n";
if ($label !== null && $label !== '') {
$content .= $label . " :\n";
}
$content .= print_r($vars, true) . "\n";
}
if ($return) {
return $content;
}
echo $content;
return null;
}
/* 不好的例子
$query = "select * from entreprise";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result)){
$query2 = "select * from site where entreprise_id = $row[entreprise_id]";
$result2 = mysql_query($query2);
$a2 = array();
while($row2 = mysql_fetch_assoc($result2)){
$query3 = "select * from salarie where site_id = $row2[site_id]";
$result3 = mysql_query($query3);
while($row3 = mysql_fetch_assoc($result3)){
$a3[] = array("text"=>$row3[nom]);
}
if($a3[site_id] == $a2[site_id]){
$a2[] = array("text"=>$row2[nom],'children'=>$a3);
}
}
if($a2[entreprise_id] == $a1[entreprise_id]){
$a1[] = array("text"=>$row[id]." ".$row[nom],'children'=>$a2);
}
}
//print_r($a1);
//echo json_encode($a1);
dump($a1);
*/
$entreprise_q = mysql_query("select * from entreprise");
$site_q = mysql_query("select * from site");
$salarie_q = mysql_query(&quo
相关文档:
<!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=gb2312" />
<title>PHP分页</tit ......
/***************************by
garcon1986********************************/
<?php
//example1
$makefoo = true;
bar();
if($makefoo){
function foo(){
echo "doesn't exist.<br>";
}
}
if($makefoo)foo();
function bar(){
echo "exist<br>";
}
//example2
funct ......
/***************************by
garcon1986********************************/
<?php
//简单示例
class SimpleClass
{
public $var = 'a default value';
public function displayVar(){
echo $this->var;
}
}
// create an object创建一个对象
$A = new SimpleClass;
//调用方法
$A -> displayVa ......
/*********************************************************************************************
*****************************php二级联动菜单改动版***********************************
****************************************by garcon1986*****************************************
********************* ......