php - Insert form value, which retrieved from database, again in to MySQL database -
i have read-only text box retrieving max receipt no it's value, database sales
table.
<input name="txtreceiptno" type="text" id="txtreceiptno" size="10" value="<?php $receiptno = mysqli_fetch_row(mysqli_query($connection,"select max(sales_id)+1 sales")); echo $receiptno[0];?>" readonly />
when try send database, gives error.
#1054 - unknown column 'receipt_no' in 'field list'
(yes, know incorrect, how can correct this?)
sql query:
insert sales(cus_id,item_id,stock_id,receipt_no,qty,unit_price,discount,amount,user_id,purchase_id) select c.cus_id, i.item_id, s.stock_id, receipt_no='$receipt_no',st.qty, st.unit_price, st.discount, st.amount, u.id, p.purchase_id customers c, items i, stock s, sales_temp st, users u, purchase_items p st.staff='$user' , c.customer_name='$customer' , i.item_name=st.item_name , s.stock_code=st.stock_code , st.purchase_id=p.purchase_id
edited code:
insert sales(cus_id,item_id,stock_id,receipt_no,qty,unit_price,discount,amount,user_id,purchase_id) select c.cus_id, i.item_id, s.stock_id, receipt_no='$receiptno',st.qty, st.unit_price, st.discount, st.amount, u.id, p.purchase_id customers c, items i, stock s, sales_temp st, users u, purchase_items p st.staff='$user' , c.customer_name='$customer' , i.item_name=st.item_name , s.stock_code=st.stock_code , st.purchase_id=p.purchase_id
i have fixed above issue.
edited code below:
insert sales(cus_id,item_id,stock_id,receipt_no,qty,unit_price,amount,user_id,purchase_id) select c.cus_id, i.item_id, s.stock_id, $receipt_no, st.qty, st.unit_price, st.amount, u.id, p.purchase_id customers c, items i, stock s, sales_temp st, users u, purchase_items p st.staff='$user' , c.customer_name='$customer' , i.item_name=st.item_name , s.stock_code=st.stock_code , st.purchase_id=p.purchase_id
Comments
Post a Comment