php多表寫入,更新求指導

來源:互聯網
上載者:User
怎樣用php在mysql的多個表中的相同欄位下同時寫入資料呢?


回複討論(解決方案)

多個表中的相同欄位同時寫入
這顯然這設計不合理了
雖然關係型資料庫會有一些冗餘,但也不是像你這樣的

可以執行多個sql


$username = $_POST['username'];
$password = $_POST['psd'];
$sex = $_POST['sex'];
$grade = $_POST['grade'];
$age = $_POST['age'];
$height=$_POST['height'];
$weight=$_POST['weight'];

//檢查表單資料
if(!preg_match('/^[\w\x80-\xff]{3,15}$/', $username)){
exit('錯誤:使用者名稱不符合要求!back');
}
if(strlen($password) < 6){
exit('錯誤:密碼長度不符合要求!back');
}


include('conn.php');


$sql = "INSERT INTO user(username,password,sex,grade,age,height,weight)VALUES('$username','$password','$sex','$grade','$age','$height','$weight')";
INSERT INTO module1(username)VALUES('$username');
INSERT INTO module2(username)VALUES('$username');
INSERT INTO module3(username)VALUES('$username');
INSERT INTO module4(username)VALUES('$username');
INSERT INTO module5(username)VALUES('$username');
if(mysql_query($sql,$conn))
exit('註冊成功!點擊此處登入');
else
echo '抱歉,註冊錯誤!:',mysql_error(),'
';
echo '點擊此處返回 重試';

?>

這個怎麼改?

你結貼率太低了

相同 和同時是個什麼概念 你能說得更詳細點?

我已經成功了,謝謝諸位了,PS我不是結貼率低,而是在一段時間內寫了太多新帖,加權平均後。。。。就成了你所見到的情境,所以我覺得其實論壇的結貼方式與演算法有待改進

  • 聯繫我們

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