radio的值如何寫入資料庫

來源:互聯網
上載者:User
radio的值怎麼寫入資料庫
本帖最後由 lihui4512z 於 2014-07-03 17:21:43 編輯



其他幾列都是動態擷取的,都能夠成功寫入資料庫。

現在問題就在這一句

正常
不正常


感覺name這樣定義好像不對,但又不知道怎麼弄了。請問怎樣可以將radio選中的值寫入資料庫?name不好用常量。


附整個表單代碼:





【cldj.php】

header("Content-type: text/html; charset=utf-8");
require ('common.php');

$hh=$_POST['hao1'];
$aa=$_POST['bh'];
$bb=$_POST['xm'];
$cc=$_POST['fangfa'];
$dd=$_POST['biaozhun'];
$_gh=$_COOKIE["name"];
$_time=$_POST['time'];

$name=implode(_fetch_array_list(mysql_query("SELECT name FROM jsy WHERE gonghao = $_gh")));

if (is_array($aa)){
foreach ($aa as $i=>$v){
mysql_query("INSERT INTO djjl (hao,bh,xm,fangfa,biaozhun,gonghao,name,time,zt) VALUES (
'$hh',
'$v',
'{$bb[$i]}',
'{$cc[$i]}',
'{$dd[$i]}',
'$_gh',
'$name',
'$_time'

)" )or die('SQL執行失敗!'.mysql_error());}}
mysql_close();
_alert_location('添加成功!','ksdj.php');
?>

------解決方案--------------------
你那樣定義name,後台還有重組數組格式。建議你這樣定義name值:
name="post[$_rows['bh']]['bh']"
name="post[$_rows['bh']]['xm']"
這樣每一行就是一個數組。
後面的radio也是一樣, name="post[$_rows['bh']]['status']"
------解決方案--------------------
引用:
你那樣定義name,後台還有重組數組格式。建議你這樣定義name值:
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.