首页 Soft PlugIn RAN乱 Dev开发 Info资料 English WAP 留言 登陆 注册
-
Posted by Yippee | 评论(1) | 引用(0) | 阅读3544次
PHP MYSQL 通用数据处理 JAVASCRIPT 传值 调用 代码

PHP MYSQL 通用数据处理 JAVASCRIPT 传值 调用 PHP代码

PHP MYSQL 通用数据处理 JAVASCRIPT 传值 调用 HTML http://www.shengfang.org/blog/p/lampTYDATAjsphphtml.php
<html> www.shengfang.org
<HEAD>
<title>例子</title> www.shengfang.org
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<?php   www.shengfang.org
#setcookie("TestCookie", $value, time()+3600);  /* expire in 1 hour */
function GetDepart($id=0)
{ www.shengfang.org
  require_once('./adodb/ADOdb-errorhandler.inc.php');
  require_once("./adodb/ADOdb.inc.php");
  require_once('./adodb/tohtml.inc.php');
  $conn = &ADONewConnection('mysql');  # create a connection
  $conn->PConnect('localhost','root','123','bill');# connect to MySQL, agora db   
  $id=$_COOKIE['usersfsf'];
  print_r($_COOKIE); //备注:测试使用
  echo "idd='$id';";  
  $sqll='select departmentname,departmentid  from departments  where companyid =  '.$id;
  echo "sql='$sqll';";
  $recordSet = &$conn->Execute($sqll);
  #print $recordSet->GetMenu("sdfsd","",false);
  #rs2html($recordSet);
  #echo '<Script LANGUAGE=JavaScript>';
  echo "var y=new Array();";
  $i=0; 
  while (!$recordSet->EOF)
  {
   #$smenu[]  =  $recordSet->fields[0]; 
   $s=$recordSet->fields[0];
   echo "y[$i]='$s';";
   $i=$i+1;
   $recordSet->MoveNext();
   }
  #echo "</script>";
  if  (!isset($smenu)  &&  is_array($smenu))
  {  
   $str  =  implode(",",$smenu); 
   #echo '<Script LANGUAGE=JavaScript>';
   echo "y='$str'";
   #echo "</script>";
   }
  unset($smenu);  //删除smenu变量 
}
?>
<?php  www.shengfang.org
function GetCompanys($id=0)
{
  require_once('./adodb/ADOdb-errorhandler.inc.php');
  require_once("./adodb/ADOdb.inc.php");
  require_once('./adodb/tohtml.inc.php');
  $conn = &ADONewConnection('mysql');  # create a connection
  $conn->PConnect('localhost','root','123','bill');# connect to MySQL, agora db   
  
  $recordSet = &$conn->Execute('select companyname,companyid  from companys');
  #print $recordSet->GetMenu("sdfsd","",false);
  #rs2html($recordSet);
  //echo '<Script LANGUAGE=JavaScript>';
  echo "var companyname=new Array();";
  echo "var companyid=new Array();";
  $i=0; 
  while (!$recordSet->EOF)
  {
   #$smenu[]  =  $recordSet->fields[0]; 
   $s=$recordSet->fields[0];
   echo "companyname[$i]='$s';";
   $s=$recordSet->fields[1];
   echo "companyid[$i]='$s';";
   $i=$i+1;
   $recordSet->MoveNext();
   }
  //echo "</script>";
}www.shengfang.org
 ?> 
 <?php www.shengfang.org
 function tt()
 {
  $k="sdf";
  return $k;
  }
 ?>
<SCRIPT LANGUAGE="JavaScript">

function sfsf()
{
 var  khstr="<?=tt()?>"               //先将php变量转变成javascript变量khstr。
 alert(khstr);
} www.shengfang.org
function  qwer2()
{    www.shengfang.org
 
 <? GetCompanys()?>
 with  (document) 
 {  
  
  for(i=all("mmenu").options.length;i>=0;i--)
  {  
   all("mmenu").options.remove(i);  //需要清除原有的项目 
   } 
  for(i=0;i<companyname.length;i++)
  {  
   //obj1=document.createElement("option"); 
   //obj1.text=companyname[i]; 
   //obj1.value=companyid[i]; 
   var obj1=new Option(companyname[i],companyid[i]);
   all("mmenu").options.add(obj1); 
   
   } 
  } 

function  qwer(pSelect)
{    www.shengfang.org
 expireDate = new Date ;
 //document.cookie="userName='"+pSelect+"'; expires="+expireDate.toGMTString() ;
 delCookie("TestCookie");
 delCookie("usersfsf");
 alert(document.cookie);
 setCookie("usersfsf",pSelect);
 alert(document.cookie);
 <? GetDepart()?>
 alert(sql);
 alert(idd);
 with  (document) 
 {  
  for(i=all("smenu").options.length;i>=0;i--)
  {  
   all("smenu").options.remove(i);  //需要清除原有的项目 
   } 
  for(i=0;i<y.length;i++)
  {  
   obj=document.createElement("option"); 
   obj.text=y[i]; 
   all("smenu").options.add(obj); 
   
   } 
  } 

 www.shengfang.org
</script>
<select name="mmenu" onChange="qwer(this[this.selectedIndex].value)">

</select> 
<SCRIPT LANGUAGE="JavaScript">
function setCookie(name,value)
{
 var Days = 30;
 var exp = new Date(); //new Date("December 31, 9998");
 exp.setTime(exp.getTime() + Days*24*60*60*1000);
 document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
www.shengfang.org
function getCookie(name)
{
 thisCookie=document.cookie.split("; ");
 for (i=0; i<thisCookie.length;i++)
 {
  temp=thisCookie[i].split("=");
  //alert(temp);
  if(temp[0]==name)
   return temp[1];
  else
   return null;
  //alert("', and the value is '"+thisCookie[i].split("=")[1]+"'<BR>");  
  }
 //var arr,reg=new RegExp("(^ | )"+name+"=([^;]*)(; |$)");
 /*var arr,reg=new RegExp("(^ | )"+name+"=([^;]*)(; |$)");
 alert(reg);
 if(arr=document.cookie.match(name))
  return unescape(arr[2]);
 else
  return null; */
www.shengfang.org
function delCookie(name)
{
 var exp = new Date();
 exp.setTime(exp.getTime() - 1);
 var cval=getCookie(name);
 if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

//expireDate = new Date ;
//document.cookie="userName=sfsf; expires="+expireDate.toGMTString() ;
//setCookie("usersfsf","sssssssss");
//alert(getCookie("usersfsf"));
//uu="1234";
//alert(document.cookie);
<?php www.shengfang.org
 $value = 'something from somewhere';
 $uuu=$_COOKIE['usersfsf'];
 #echo "uu='$uuu';";
?>
/*alert(uu);
delCookie("usersfsf");
alert(thisCookie);
if (document.cookie == "")
{
 alert("There are no cookies here");
}
else
{   www.shengfang.org
 thisCookie=document.cookie.split("; ");
 alert(thisCookie);
 for (i=0; i<thisCookie.length;i++)
 {
  temp=thisCookie[i].split("=");
  //alert(temp);
  //alert("Cookie name is ':"+temp[0]);
  //alert("', and the value is '"+thisCookie[i].split("=")[1]+"'<BR>");  
  }
}
*/
qwer2();
</script> www.shengfang.org
<select  name="smenu">  //子菜单设计 
</select> 
<input name='sf' >
</html>


字体:

Permanant URI永久地址 http://www.shengfang.org/blog/p/lampTYDATAjsphpcode.php
Trackback URI引用地址 http://www.shengfang.org/blog/tb.php?tb_id=1130803127

2005年11月1日07:58星期二  [Dev开发] 追踪此文的RSS
ennemxhqnw在 2008年3月23日20:15星期日 评论:
<a href="http://vysaho.com">nanahy</a> | [url=http://vyxura.com]woveho[/url] | [link=http://sesete.com]recusy[/link] | http://rynuza.com | weryna | [http://pekewu.com vihahu]

称呼:    登陆   注册
   不注册,但记住我的信息
邮件:
(非必须)
评论: [UBB代码帮助]
粗体 斜体 下划线 链接 水平线 引用



验证码: 请输入你看见的数字
关闭UBB      提交时自动将内容复制到剪贴板

公告





统计信息
[Yippee]||[统计]||日志:2143
在线: 18||用户: 2635 [列表]
今日:629||到访:3654414
Rss:||评论:1668

最新日志

最新评论

友情链接

日历
342009 - 0734
   1234
567891011
12131415161718
19202122232425
262728293031 

最新引用
搜索

归档

杂项
Get RSS Feed (Version 2.0)
Get Atom Feed (Version 0.3)
编码:  UTF-8