postgresql - How to insert data in 2 table & check if data already excist in DB in php -


How can I insert data into 2 tables? Check whether the data already exists or not? I am using PHP and Postgres DB My php code (I call it)

I will not paste other code to keep it short) I know how to insert using only 1 table. I should make pg_query for another tbl_ingredient :

$ addItem = pg_query ("tbl_item values" (select '$ ITEMNAME')

And how can I check that the data already exists? I want to see data on 3 columns.

  $ CheckItemname = pg_query ("Select from tbl_item * where ITEMNAME = '" $ ITEMNAME.); If (pg_num_rows ($ CheckItemname) == 1) {Warning (' '.. $ ITEMNAME' 'item Already exists');}  

I have tried to add ( & amp; (pg_num_rows ($ CheckHighQntyThreshold) == 1) Amp; & amp; (pg_num_rowshold ($ checkLowQntyThreshold == 1)) But anyway Adobe Dreamweaver is marking it red

First of all, I firmly recommend Pg_ * to use instead of functions, because there are some security problems with them.

Yes, you have a And the query must be entered, as before.

If you want the check data to exist, you can do something like:

  select count (*) tbl_item where ITEMNAME = 'your_item' < / Code> 

and from nb_result then, if nb_result> 0

check

Comments