寫菜單思路卡主了,求大神

來源:互聯網
上載者:User

本人PHP菜鳥,遇到了這個問題卡主了,想選擇套餐,就直接插入菜品欄,sql語句卡主了。。不知道咋往下寫了

A表:bigtype【2】 B表:smalltype【3】

if(isset($_POST['submit'])){    $cd=$_POST['bigtype'];    $query="insert into smalltype·······求大神幫忙····"}

回複內容:

本人PHP菜鳥,遇到了這個問題卡主了,想選擇套餐,就直接插入菜品欄,sql語句卡主了。。不知道咋往下寫了

A表:bigtype【2】 B表:smalltype【3】

if(isset($_POST['submit'])){    $cd=$_POST['bigtype'];    $query="insert into smalltype·······求大神幫忙····"}

$query="INSERT INTO smalltype (bid,smalltype)VALUES('".mysql_real_escape_string($bid)."','".mysql_real_escape_string($smalltype)."')";

是用ID去關聯2個表嗎?
如果是的話,假設前表為A,後表為B
select A.* from A ,B where A.id=B.id and B.bigtype='變數參數';

phpif(isset($_POST['submit'])){    $big_type = $_POST['bigtype'];    $small_type = $_POST['small_type'];    $query="INSERT INTO smalltype (bid, smalltype)VALUES(".quote($big_type).",".DB::quote($small_type).")";    DB::query($query);}

沒有看懂想做什麼……
資料庫不要增加冗餘資訊,bigtype和small分兩個表的話沒有必要把bigtype再複製一遍放到smalltype裡,應該在SELECT時用union連起來

應該是根據$cd=$_POST['bigtype'],select B表擷取BID,然後再插入A表(BID,smalltype)

這個應該是後台返回全部資料JSON,前端JS控製取比較合適吧。

  • 聯繫我們

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