程序我改了,但一直提示
Notice: Undefined variable: k阶段: in D:\Inetpub\wwwroot\yx\chdrpf_gss.php on line 39Notice: Undefined offset: 1 in D:\Inetpub\wwwroot\yx\chdrpf_gss.php on line 39Notice: Undefined offset: 1 in D:\Inetpub\wwwroot\yx\chdrpf_gss.php on line 39
就是这一句:sudate = sudate."第$k阶段:".$start_date[$k]."-".$end_date[$k]."<br>";
Notice: Undefined variable: k阶段: in D:\Inetpub\wwwroot\yx\chdrpf_gss.php on line 39Notice: Undefined offset: 1 in D:\Inetpub\wwwroot\yx\chdrpf_gss.php on line 39Notice: Undefined offset: 1 in D:\Inetpub\wwwroot\yx\chdrpf_gss.php on line 39
就是这一句:sudate = sudate."第$k阶段:".$start_date[$k]."-".$end_date[$k]."<br>";
$m="1";
$m[0]="23";
echo $m;
?>
这个可以给你点启示,别把一个变量同时有当成数组来赋值。
session_start();
if (isset($_POST['add'])){
$_SESSION['start_date'][] = $_POST['start_date'];
$_SESSION['end_date'][] = $_POST['end_date'];
$k = count($_SESSION['start_date'])-1;;
sudate = sudate."第$k阶段:".$start_date[$k]."-".$end_date[$k]."<br>";
echo $sudate;
}
sudate = sudate."第$k阶段:".$start_date[$k]."-".$end_date[$k]."<br>";
改做
sudate = sudate."第$k阶段:".$_SESSION['start_date'][$k]."-".$_SESSION['end_date'][$k]."<br>";