php+mysql 怎么用循环的方式把表单内容update到数据库

WBOY
Release: 2016-06-13 13:15:13
Original
889 people have browsed it

php+mysql 如何用循环的方式把表单内容update到数据库
我目前需要在一个网页动态创建表格,比如10行,填写表格后通过表单提交
代码如下:

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->    
        echo "
Copy after login
"; $i = 0; while($row = mysql_fetch_array($result)) { echo ""; echo ""; echo "";//数据表中已经有文件名和文件大小,但是播放时间都默认为0,通过网页修改来update数据库 echo ""; echo ""; echo ""; echo ""; } echo ""; echo "
"; echo ""; echo "
文件名 文件大小 播放时间1 播放时间2 播放时间3
" . $row['filename'] . "" . $row['filesize'] . " \" type=\"text\"> \" type=\"text\"> \" type=\"text\">
";


我想在process.php中进行处理,
$w = 0;
while($row = mysql_fetch_array($result))
{
$filename = $row['filename'];
$time1 = $_POST["$w"];
$w++;
$time2 = $_POST["$w"];
$w++;
$time3 = $_POST["$w"];
$w++;
echo "此时的w=".$w."
";
$sql = "UPDATE fileinfo SET time1='".$time1."',time2='".$time2."',time3='".$time3."' WHERE filename='".$filename."'";
$re = mysql_query($sql) or die("error:".mysql_error());
echo $sql."---结果是:".$re."
";
}

post过来的$time1,$time2,$time3都是空值,改成$time1 = $_POST[$w]也不行,$time1 = $_POST['$w']也不行,不知道$_POST[]里面的值能否是变量,该怎么表示啊。。。。怎么处理这种提交一个表格的情况!!

------解决方案--------------------
你查看一下前台页面,命名对吗?
------解决方案--------------------
这样试试
PHP code
 $i = 0;
    while($row = mysql_fetch_array($result))
    {
        echo "<tr>";
        echo "<td>" . $row['filename'] . "</td>";
        echo "<td>" . $row['filesize'] . "</td>";//数据表中已经有文件名和文件大小,但是播放时间都默认为0,通过网页修改来update数据库

        echo "<td>
<input name='\"<?php' echo>\" type=\"text\"></td>";
        echo "<td>
<input name='\"<?php' echo>\" type=\"text\"></td>";
        echo "<td>
<input name='\"<?php' echo>\" type=\"text\"></td>";
        echo "</tr>";
 $i++;
    }
<br><font color="#e78608">------解决方案--------------------</font><br>你先 print_r($_POST); 看看
<br><font color="#e78608">------解决方案--------------------</font><br>echo "<td>
<input name='\"<?php' echo>\" type=\"text\"></td>";<br>echo "<td>
<input name='\"<?php' echo>\" type=\"text\"></td>"; <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template