2011-09-02 28 views

回答

0

您需要迭代!換句話說..一個循環。

下面

大量註釋未經測試的例子:

$i = 0; // Needed to have different variable names 
foreach($varw as $var){ 
    print "<input type=\"hidden\" name=\"". weight{$i} . "\" value=\"" . $var . "\">"; 
    $i++; // increment counter on each iteration ... 
} 

// You will now have as many hidden fields as $varw's. 

我離開你想出的循環,將做插入數據庫的樂趣。

閱讀for loops手冊,

編碼愉快的朋友。

PS:請不要用大寫字母開頭變量名和函數名。

+0

這會產生此錯誤:解析錯誤:語法錯誤,意外的'{'在/home/blah/public_html/blah.php在39行 –

0

使用Mysql deleminator';'到seprate兩個查詢,並在循環使用它

0

你總是可以使用JSON或逗號(通過implode())分隔值

Print "<input type='hidden' name='Weight' value=" . json_encode($varw) . ">"; 

在你的PHP端,當你收到此你可以使用json_decode()回數組或者如果決定使用逗號分隔值,則通過「,」使用explode()將其拆分爲數組。

相關問題