对C中的数组做个备份,A中修改过之后来检测一下备份和原件是否一致,不一致的话就更新C中数组的数据,这样B中每次用到的都是修改过的数据了。
解决方案 »
- 请教这段多条件搜索代码为什么搜不出结果
- 一个很菜的问题
- PHP URL传递中文出现乱码
- 匹配字母,数字,空格,以及! " # $ % & ' ( ) = ~ | - ^ \ @ [ ; : ] , . / ` { + * } < > ? _的正则表达式
- 如何讲一个数组的每项写入一个文件
- 紧急求救!!请高手们帮忙解决一个特大问题,网站出现了乱码,可能是被人家黑的!
- php中如何自動取得每週的週一日期?
- 高分求救:那里有支持上传图片的php论坛代码?
- 散分啦,发表我的新软件“网海收藏家 XP”
- 怎样用javascript的if语句控制 PHP?
- php如何把gb2312字符串转换为unicode字符串呢?
- 数据库乱码
<?php
//建立数据库连接,把数据库里的数据插入到数组
$link=mysql_connect('localhost:6033','root','root');
mysql_select_db("2008");
mysql_query("SET NAMES GBK");
$query="select * from question";
$result=mysql_query($query);
$arr=array();
?>//question.php
<!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>2008</title>
</head>
<body>
<form id="form1" name="question" method="post" action="tijiao.php">
<?php
include("connect.php");
while($answer=mysql_fetch_object($result))
{
array_push(&$arr,$answer);
}
shuffle(&$arr);
for($i=0;$i<30;++$i)
{
echo '<p>'.($i+1).'. ' .$arr[$i]->timu.'</p>';
echo '<p><input type="radio" name='."ans_$i".' value="a" />'.$arr[$i]->ans1;
echo '<input type="radio" name='."ans_$i".' value="b" />'.$arr[$i]->ans2;
echo '<input type="radio" name='."ans_$i".' value="c" />'.$arr[$i]->ans3.'</p>';
}
echo '<p><input type="submit" name="Submit" value="答题完毕" /></p></form>';
?>
<?php
mysql_close($link);
?>
</body>
</html>//tijiao.php
<?php
include("connect.php");
var_dump($arr);
?>
我就是想要tijiao.php里能用到question.php修改后的数组... 应该怎么办? 直接包含question.php不行,因为有执行语句..
刚学PHP几天还不是太懂,希望大家给点提示
但是tijiao.php包含了这一文件后 显示的数组仍然是没修改过的数组啊!
在tijiao.php页面在提取
<?php
//建立数据库连接
$q_link=mysql_connect('localhost:6033','root','root');
mysql_select_db("2008");
mysql_query("SET NAMES GBK");
?>//question.php
<?php
session_start();
?>
<!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>2008</title>
</head>
<body>
<form id="form1" name="question" method="post" action="tijiao.php">
<?php
$username=$_POST['uname'];
$userqq=$_POST['uqq'];
include("connect.php");
include("var.inc");
if(empty($username)||empty($userqq))
{
echo '姓名或QQ号不能为空,请返回<a href="index.html">重新填写</a>';
exit;
}
$insert="INSERT INTO `2008`.`user` (`name` ,`qq` ,`count` ,`time`) VALUES ('".$username."','".$userqq."', 0, 0);";
mysql_query($insert);
$query="select * from question";
$result=mysql_query($query);
while($answer=mysql_fetch_object($result))
{
array_push($arr,$answer);
}
shuffle(&$arr);
$_SESSION['arr'];
for($i=0;$i<30;++$i)
{
echo '<p>'.($i+1).'. ' .$arr[$i]->timu.'</p>';
echo '<p><input type="radio" name='."ans_$i".' value="a" />'.$arr[$i]->ans1;
echo '<input type="radio" name='."ans_$i".' value="b" />'.$arr[$i]->ans2;
echo '<input type="radio" name='."ans_$i".' value="c" />'.$arr[$i]->ans3.'</p>';
}
echo '<p><input type="submit" name="Submit" value="答题完毕" /></p></form>';
$time
?>
<?php
mysql_close($q_link);
?>
</body>
</html>//tijiao.php
<?php
session_start();
include("connect.php");
$arr=$_SESSION['arr'];
var_dump($arr);
/*
$query="select * from user where name=$_POST['uname']";
$result=mysql_query($query);
$answer=mysql_fetch_object($result);
echo "$answer->name 您本次答题信息如下: <br>";
echo "回答正确:$answer->count<br>";
echo "所用时间:$answer->time";
*/
?>
//var.inc
<?php
$arr=array();
?>
应该是把修改好的数组传给session
$_SESSION['arr']=$arr;