问个关于数组传值的问题,在线等~~

Kingdyjz 2004-04-13 03:40:33
我有个程序,类似51job里面“订阅工作”页面里的内容,左右各有一个列表框(list1,list2),中间一个按钮,点击后把从list1里选定的值value1传到list2里,我做了一个数组(array),在点击按钮的时候,我把list2里的值value2提取出来,放进array里面,把array和value1一起通过表单传递给本页面,把value1放进array里面,组成一个新的value2,再把value2放进list2里面,这样不断循环,可是做的时候array似乎不能被重新赋值,请问这怎么解决??或者有什么更好的方法,请教一下~~谢谢~~
...全文
87 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Kingdyjz 2004-04-14
  • 打赏
  • 举报
回复
这个是DY.php
class diaoyong
{
function diaoyong()
{
$this->my_Conn();
}
function my_Conn()
{
$host = "localhost";
$user = "root";
$passwd = "root";
$conn=mysql_connect($host,$user,$passwd) or die(+mysql_error());
mysql_select_db("jiaxiaotong",$conn) or die (+mysql_error());
}
function my_chulilogin($sql)
{
$result=mysql_query($sql);
$array["result"]=$result;
$row=@mysql_fetch_array($result);
$array["rows"]=$row;
$array["count_row"]=@mysql_num_rows($result);
return $array;
}
}
Kingdyjz 2004-04-14
  • 打赏
  • 举报
回复
这个是我做的程序:
<?php
include 'DY.php';
$array1=array("","全部","一(1)班","一(2)班");
$select1_value=@$HTTP_GET_VARS["inde"];
$select2_value=@$HTTP_GET_VARS["inde1"];
if($select2_value==NULL||$select2_value==0||$select2_value=="")
{
echo "传过来的值为空啊";
$select3_array=array();
$chuan=array();
}
else
{
echo @"第一次传过来的"."-----".count(@$_POST["array_tmp"]);
$select3_array=array();

for($j=0;$j<count(@$_POST["array_tmp"]);$j++)
{
$select3_array[$j]=@$_POST["array_tmp"][$j];
}
echo "传过来的"."-----".count($select3_array);
if(count($select3_array)==0)
{
$select3_array[0]=$select2_value;
echo "zxcv".$select3_array[0];
echo "select3_array的值是: ".count($select3_array);
}
else
{
array_push($select3_array,$select2_value);
echo "zxcvsdfsdf".count($select3_array);
}
}
$select3_value=@$HTTP_GET_VARS["inde2"];
$biaoshi=@$HTTP_GET_VARS["biaoqian"];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>向导1</title>
</head>
<script language="JavaScript" type="text/javascript">
function mmm()
{
window.location="send_1.php?inde="+document.all.select1.value+"";
}
function mm1()//全部向右移
{
window.location="send_1.php?inde="+document.all.select1.value+"&biaoqian=quan1";
}
function mm2()//全部向左移
{
window.location="send_1.php?inde="+document.all.select1.value+"&biaoqian=quan2";
}
function m1()//向右移
{
window.location="send_1.php?inde="+document.all.select1.value+"&inde1="+document.all.select2.value+"";
}
function m2()//向左移
{
window.location="send_1.php?inde="+document.all.select1.value+"&inde2="+document.all.select3.value+"";
}
</script>
<body>
<table width="450" height="308" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="26" align="left" valign="bottom">请选择发送对象</td>
</tr>
<tr>
<td height="248"><form name="form1" method="post" action="">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="26%" height="24" align="center">班级:</td>
<td width="48%" height="24"> </td>
<td width="26%" height="24"> </td>
</tr>
<tr>
<td height="31" align="center">
<select name="select1" onChange="mmm()">
<?php
if($select1_value!=NULL||$select1_value!=0)
{
for($i=0;$i<count($array1);$i++)
{
if($select1_value==$array1[$i])
{
echo "<option name=\"select1\" value=\"$array1[$i]\" selected>$array1[$i]</option>";
}
else
{
echo "<option name=\"select1\" value=\"$array1[$i]\">$array1[$i]</option>";
}
}
}
else
{
echo "<option name=\"select1\" value=\"$array1[0]\" selected>$array1[0]</option>";
for($i=1;$i<count($array1);$i++)
{
echo "<option name=\"select1\" value=\"$array1[$i]\">$array1[$i]</option>";
}
}
?>
</select>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="22" align="center"> 学生:</td>
<td> </td>
<td align="center">选择的学生:</td>
</tr>
<tr>
<td rowspan="6" align="center">
<select name="select2" size="8">
<?php
if($select1_value!=NULL||$select1_value!=0)
{
$panduan=false;
$sql="";
$diao=new diaoyong;
for($i=0;$i<count($array1);$i++)
{
if($select1_value==$array1[$i])
{
$panduan=true;
break;
}
}
if($panduan==true)
{
if($select1_value=="")
{
$sql="select student_id,student_name from student_xx where banji='****'";
}
else if($select1_value=="全部")
{
$sql="select student_id,student_name from student_xx";
}
else
{
$sql="select student_id,student_name from student_xx where banji='$select1_value'";
}
$array=$diao->my_chulilogin($sql);
for($j=0;$j<$array["count_row"];$j++)
{
$zhi1=mysql_result($array["result"],$j,"student_id");
$zhi2=mysql_result($array["result"],$j,"student_name");
echo "<option name=\"select2\" value=\"$zhi1\">$zhi2</option>";
}
}
else
{
?>
<script language="JavaScript">
alert("对不起请不要恶意破坏");
</script>
<?
}
}
?>
</select></td>
<td align="center"> </td>
<td rowspan="6" align="center"><select name="select3" size="8">
</select></td>
</tr>
<tr>
<td align="center"><input type="button" name="Submit2" value=" >>"> </td>
</tr>
<tr>
<td align="center"><input type="button" name="Submit5" value="<<"> </td>
</tr>
<tr>
<td align="center"><input type="button" name="Submit3" value=" > " onClick="m1()">
<?
echo @"在下面的".count($select3_array);
if(count($select3_array)>0)
{
for($i=0;$i<count($select3_array);$i++)
{
$chuan[$i]=$select3_array[$i];
}
for($i=0;$i<count($select3_array);$i++)
{
unset($select3_array[$i]);
}
}
echo @"chuan".@count($chuan);
echo "<input type=\"hidden\" id=\"array_tmp\" value=\"$chuan\"></input>";
?>
</td>
</tr>
<tr>
<td align="center"><input type="button" name="Submit4" value=" < "></td>
</tr>
<tr>
<td align="center"> </td>
</tr>
</table></form></td>
</tr>
<tr>
<td height="30" align="right" valign="top">
<form name="form2" method="post" action="">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="right">
<td>
<input type="submit" name="Submit" value="<上一步">   
<input type="submit" name="Submit6" value="下一步>">   
<input type="reset" name="Submit7" value="取消">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
52juanjuan 2004-04-14
  • 打赏
  • 举报
回复
不好说了,先看看吧
cokeyang 2004-04-14
  • 打赏
  • 举报
回复
从新赋值前先用array()清空
ccterran 2004-04-13
  • 打赏
  • 举报
回复
晕倒,又花了

<html>
<head>
<title>PHP在线后台管理系统后台管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="doc/style.css">

<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

//-->
</script>

<script language="JavaScript">
<!--
var currentclassid = 5;
//mask errors
//function killErrors(){
// return TRUE;
//}
//window.onerror=killErrors;
//check all elements
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name != 'chkall'&&e.disabled!=true)
e.checked = form.chkall.checked;
}
}
//windo open
function MM_openWindow(theURL,winName,features) { //v2.0
var new1=window.open(theURL,winName,features);
new1.focus();
}

function add() {
var all = document.getElementById("all");
var user = document.getElementById("user");
var max = all.options.length;
for (var i=0;i<max;i++) {
if (all.options[i].selected) {
for (var j=0;j<user.options.length;j++) {
if (user.options[j].text == all.options[i].text) {
alert("您不能重复加入");
return;
}
}
user.options.add(new Option(all.options[i].text,all.options[i].value));
}
}
}
function remove() {
var user = document.getElementById("user");
var max = user.options.length - 1;
for (var i=max;i>=0;i--) {
//alert(user.options[i].selected);
if (user.options[i].selected) {
user.options.remove(i);
}
}
}
//-->
</script>
</head><SCRIPT language=vbscript>
<!--
sub all_ondblClick
call add
end sub
sub user_ondblClick
call remove
end sub
-->
</SCRIPT>
<script>
function checkform(){
for (var i=0;i<form1.elements['user[]'].length;i++){
form1.elements['user[]'].options[i].selected=true;
}
form1.submit();
}
</script>


<form name="form1" action="index.php?action=encp" method="post" onsubmit="javascript:checkform()">
<TABLE cellSpacing=0 width="100%" align=center border=0>
<TBODY>
<TR>
<TD width="20%">
</TD>
<TD width="30%">
<select id=all style="WIDTH: 140px; HEIGHT: 220px" size=12 name=all multiple>
<option value="0">编辑库</option>
<option value="4">分类管理</option>
<option value="5">发布库</option>
<option value="6">热字管理</option>
<option value="7">发稿日历</option>
<option value="8">模板管理</option>
<option value="9">图片库</option>
<option value="10">评论管理</option>
<option value="11">文件管理</option>
<option value="12">用户管理</option>
<option value="13">系统设置</option>
<option value="14">运行记录</option>
<option value="17">稿源库</option>
<option value="18">投票系统</option>
<option value="1">个人设置</option>
<option value="2">个人SMS</option>
<option value="3">数据中心</option>
</select>
</TD>
<TD vAlign=center width="20%">
<INPUT onclick=add() type=button value="添加>>>" style="border:0px;background-color:999999">
<br>
<BR>
<INPUT onclick=remove() type=button value="删除<<<" style="border:0px;background-color:999999">
<br>
<br>

<input type="submit" name="Submit" value="提交配置" style="border:0px;background-color:999999">
<br>
<br>
</TD>
<TD vAlign=bottom width="30%">
<select id=user name=user[] multiple style="WIDTH: 140px; HEIGHT:220px" >
</select>
</TD>
</TR></TBODY></TABLE>
</form>
</td></tr></table><p><div align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <div align="center" style="font-size:12px">本页中使用的queries:<font color="0000FF">1 </font> 花费时间:<font color="0000FF">0.03063</font></div></td></tr></table></div></body></html>
ccterran 2004-04-13
  • 打赏
  • 举报
回复
这个?

<html>
<head>
<title>PHPÔÚÏߺǫ́¹ÜÀíϵͳºǫ́¹ÜÀíϵͳ</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="doc/style.css">

<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

//-->
</script>

<script language="JavaScript">
<!--
var currentclassid = 5;
//mask errors
//function killErrors(){
// return TRUE;
//}
//window.onerror=killErrors;
//check all elements
function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name != 'chkall'&&e.disabled!=true)
e.checked = form.chkall.checked;
}
}
//windo open
function MM_openWindow(theURL,winName,features) { //v2.0
var new1=window.open(theURL,winName,features);
new1.focus();
}

function add() {
var all = document.getElementById("all");
var user = document.getElementById("user");
var max = all.options.length;
for (var i=0;i<max;i++) {
if (all.options[i].selected) {
for (var j=0;j<user.options.length;j++) {
if (user.options[j].text == all.options[i].text) {
alert("Äú²»ÄÜÖظ´¼ÓÈë");
return;
}
}
user.options.add(new Option(all.options[i].text,all.options[i].value));
}
}
}
function remove() {
var user = document.getElementById("user");
var max = user.options.length - 1;
for (var i=max;i>=0;i--) {
//alert(user.options[i].selected);
if (user.options[i].selected) {
user.options.remove(i);
}
}
}
//-->
</script>
</head><SCRIPT language=vbscript>
<!--
sub all_ondblClick
call add
end sub
sub user_ondblClick
call remove
end sub
-->
</SCRIPT>
<script>
function checkform(){
for (var i=0;i<form1.elements['user[]'].length;i++){
form1.elements['user[]'].options[i].selected=true;
}
form1.submit();
}
</script>


<form name="form1" action="index.php?action=encp" method="post" onsubmit="javascript:checkform()">
<TABLE cellSpacing=0 width="100%" align=center border=0>
<TBODY>
<TR>
<TD width="20%">
</TD>
<TD width="30%">
<select id=all style="WIDTH: 140px; HEIGHT: 220px" size=12 name=all multiple>
<option value="0">±à¼­¿â</option>
<option value="4">·ÖÀà¹ÜÀí</option>
<option value="5">·¢²¼¿â</option>
<option value="6">ÈÈ×Ö¹ÜÀí</option>
<option value="7">·¢¸åÈÕÀú</option>
<option value="8">Ä£°å¹ÜÀí</option>
<option value="9">ͼƬ¿â</option>
<option value="10">ÆÀÂÛ¹ÜÀí</option>
<option value="11">Îļþ¹ÜÀí</option>
<option value="12">Óû§¹ÜÀí</option>
<option value="13">ϵͳÉèÖÃ</option>
<option value="14">ÔËÐмǼ</option>
<option value="17">¸åÔ´¿â</option>
<option value="18">ͶƱϵͳ</option>
<option value="1">¸öÈËÉèÖÃ</option>
<option value="2">¸öÈËSMS</option>
<option value="3">Êý¾ÝÖÐÐÄ</option>
</select>
</TD>
<TD vAlign=center width="20%">
<INPUT onclick=add() type=button value="Ìí¼Ó>>>" style="border:0px;background-color:999999">
<br>
<BR>
<INPUT onclick=remove() type=button value="ɾ³ý<<<" style="border:0px;background-color:999999">
<br>
<br>

<input type="submit" name="Submit" value="Ìá½»ÅäÖÃ" style="border:0px;background-color:999999">
<br>
<br>
</TD>
<TD vAlign=bottom width="30%">
<select id=user name=user[] multiple style="WIDTH: 140px; HEIGHT:220px" >
</select>
</TD>
</TR></TBODY></TABLE>
</form>
</td></tr></table><p><div align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <div align="center" style="font-size:12px">±¾Ò³ÖÐʹÓõÄqueries:<font color="0000FF">1 </font> »¨·Ñʱ¼ä:<font color="0000FF">0.03063</font></div></td></tr></table></div></body></html>
Kingdyjz 2004-04-13
  • 打赏
  • 举报
回复
??先把帖子顶出来

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧