php+mysql 怎麼用迴圈的方式把表單內容update到資料庫

來源:互聯網
上載者:User
php+mysql 如何用迴圈的方式把表單內容update到資料庫
我目前需要在一個網頁動態建立表格,比如10行,填寫表格後通過表單提交
代碼如下:
PHP code
            echo ""; 



我想在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 "";        echo "" . $row['filename'] . "";        echo "" . $row['filesize'] . "";//資料表中已經有檔案名稱和檔案大小,但是播放時間都預設為0,通過網頁修改來update資料庫        echo "\" type=\"text\">";        echo "\" type=\"text\">";        echo "\" type=\"text\">";        echo ""; $i++;    }
------解決方案--------------------
你先 print_r($_POST); 看看
------解決方案--------------------
echo "\" type=\"text\">";
echo "\" type=\"text\">";
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.