php二级联动菜单改动版
/*********************************************************************************************
*****************************php二级联动菜单改动版***********************************
****************************************by garcon1986*****************************************
**********************************************************************************************/
2chain.php:
<mce:script language = "JavaScript"><!--
var onecount;
onecount=0;
subcat = new Array();
<?php
mysql_connect("localhost","charles","charles");
mysql_select_db( "_crm" );
$sql = "select * from site";
$result = mysql_query( $sql );
$count = 0;
while($res = mysql_fetch_row($result)){
?>
subcat[<?php echo $count ?>] = new Array("<?php echo $res[0]?>","<?php echo $res[2]?>","<?php echo $res[1]?>");
<?php
$count++;
}
echo "onecount=$count;";
?>
//联动函数
function changelocation(locationid)
{
document.myform.ctype.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][2] == locationid)
{
//var newOption1=new Option(subcat[i][1], subcat[i][0]);
//document.all.ctype.add(newOption1);
document.myform.ctype.options[document.myform.ctype.length] = new Option(subcat[i][1], subcat[i][0]);
}
}
}
// --></mce:script>
<form method="post" name="myform" action="ru_query.php">
<select name="type" onChange="changelocation(document.myform.type.options[document.myform.type.selectedIndex].value)" size="1">
<option selected value="">main</option>
<?php
$sql = "select * from entreprise";
$result = mysql_query( $sql );
while($res = mysql_fetch_row($result)){
?>
<option value="<?php echo $res[0]; ?>">
相关文档:
原文链接:http://www.phpdo.net/index.php/2010/02/10/1-13/
PHP中一个基本的脚本由两部分组成:主程序和函数。
函数不仅可以构成一个PHP脚本的基本功能,也使得程序结构化,有助于程序代码的重用。
PHP函数的调用
通过按照函数格式写出函数以及相应的参数即可,衣语法如下:
String substr(string str,int start) ......
在生产应用中,某台“Nginx+PHP+MySQL”接口数据服务器,扮演的角色十分重要,如果服务器硬件或Nginx、MySQL发生故障,而短时间内无法恢复,后果将非常严重。为了避免单点故障,我设计了此套方案,编写了failover.sh脚本,实现了双机互备、全自动切换,故障转移时间只需几十秒。
一、双机互备、全自动切换方 ......
xml标记<?php ?>
脚本风格 <script language="php"></script>
短标记<? ?>
asp标记<% %>
如果想支持短标记和asp标记,需要在php.ini中配置
short_open_tag
asp_tags
设为on ......
/***************************by
garcon1986********************************/
<?php
//if 语句
$a = $b = 3;
if($a = $b)
print "a is equal to b<br>";
//else 语句
if($a < $b){
print "a is smaller than b";
} else {
print "a is not smaller than b<br> ......
/***************************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 ......