作者hellolucky (。 归 团 中 。)
看板PHP
标题Re: [请益] 同一个 php页面的传值
时间Tue Mar 14 00:46:15 2006
※ 引述《sskywind (有股蛋蛋的哀伤..)》之铭言:
: 我想要把 record_num,在每次使用者输入一个「数字」存在 first的input里面时,
: 按下submit,可以纪录到 cookie 里面,并且把 record_num + 1,
: 然後会再 load 一次同一个页面,并且把所有输入过的input依序列出来,
: 再让使用者继续输入下一个数值。可以重复以上动作。
: 下面是我的code,一直try不出来,麻烦帮我看错在哪里 ><,谢谢。
: <?php
: if($record_num){
: $a_record = $first;
: setcookie("c_record[$record_num]", $a_record);
: $record_num++;
: }else{
: $record_num = 1;
: }
: ?>
: <html>
: <head>
: ...
: </head>
: <body>
: <?php
: $first = $_POST['first'];
: echo '<form action=try.php method="post">';
: $a_record = $first;
: $HTTP_COOKIE_VARS['c_record'][$record_num-1] = $a_record;
: for($i=0;$i<$record_num;$i++){
: echo $HTTP_COOKIE_VARS['c_record'][$i];
: }
: echo '<p>record_num</p>'.$record_num.'<br />';
: echo '<input type="text" name="first" size="12" maxlength="10" />';
: echo '<input type="hidden" name="record_num" value=$record_num />';
echo "<input type=\"hidden\" name=\"record_num\" value=\"$record_num\" />";
参考978篇
单引号和双引号的差别
你用单引号'
他输出是$record_num
用双引号"
输出才会取代变数
: echo '<input type="submit" value="确定" />';
: echo '</form>';
: ?>
: <a href=try.php?record_num=<?echo $record_num?>>确定</a>
至於这行可以不要了吧!
: </body>
: </html>
如有错误敬请指教@@"
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.73.66.188
1F:推 sskywind:谢谢你的回答 03/15 14:51