问题一:
<?php
$fname="count.dat";
$date=date('Ymd');
if (file_exists($fname)){
$comment=file($fname);
$comment=$comment[0];
$fp=fopen($fname,w);
if($date==substr($comment,0,6))
{
$comment_ok=$date.substr(++$comment,-4);
}
else
{
$comment_ok=$date.'0001';
}
fwrite($fp,$comment_ok);
}else{
$fp=fopen($fname,w);
fwrite($fp,$date.'0001');
$comment_ok=$date.'0001';
}
fclose($fp);
echo $comment_ok;
?>
问题二:
1.用session或者cookie
2.把这些显示出的数据用<input type=hidden name=name1 value="the value">写到form里面,然后提交上来。
<?php
$fname="count.dat";
$date=date('Ymd');
if (file_exists($fname)){
$comment=file($fname);
$comment=$comment[0];
$fp=fopen($fname,w);
if($date==substr($comment,0,6))
{
$comment_ok=$date.substr(++$comment,-4);
}
else
{
$comment_ok=$date.'0001';
}
fwrite($fp,$comment_ok);
}else{
$fp=fopen($fname,w);
fwrite($fp,$date.'0001');
$comment_ok=$date.'0001';
}
fclose($fp);
echo $comment_ok;
?>
问题二:
1.用session或者cookie
2.把这些显示出的数据用<input type=hidden name=name1 value="the value">写到form里面,然后提交上来。
我的问题二,您能具体点吗?
<?
$id=mssql_connect('server','sa');
$db=mssql_select_db('dbtest1');
$query="select t_name,t_age,t_city from t_table1";
$result=mssql_query($query);
if($save<>"保存") { ?>
<form name=aaa><table>
<tr><th>姓名</th><th>年龄</th><th>城市</th></tr>
<?while($r=mssql_fetch_array($result)){?>
<tr><td><input type=text name="name[]" value="<? echo $r[t_name];?>"></td>
<td><input type=text name="age[]" value="<? echo $r[t_age];?>"></td>
<td><input type=text name="city[]" value="<? echo $r[t_city]"></td>
</tr><?echo "}";?>
</table>
<input type="submit" name="save" value="保存">
</form>
<? }else {
$id=mssql_connect('server','sa');
$db=mssql_select_db('info');
for($i=0;$i<sizeof($name);$i++)
{
$query="insert T_bodyinfo(姓名,年龄,城市) values('".$name[$i]."','".$age[$i]".','".$city[$i]."')";
mssql_query($query);
}
}?>
</body></html>
没有经过具体测试,也许有一个小的语法错误,不过大体上就是这个样子
//网站计数,都是00001234等,如果我们的计数文件存放的
//都是1234,345,等,可能不足8位数,
//因此这里将前面补零,成为00001234,00000345等
function make_eight_str($str)
{
//如果字符串本身就>8,则截取前8个字符返回
if( strlen($str)>=8 ) return substr($str,0,8);
$string="";
for($i=0;$i< 8 - strlen($str);$i++) $string.="0";
$string.=$str;
return $string;
}
您给我的例子我试过了!!
按照你的写法,
<input type=submit ......>这里不能提交了,点击了按钮后,什么响应也没有了!!!