Jump to content

Update 2 record same time


christa

Recommended Posts

hi

my db table  has 2 field:

 

ID - Place

1    France

2    Germany

 

My form has 2 text field (printed with while cycle).

 

mysql_query("UPDATE mytable SET Place = '" . $_POST['place'] . "' WHERE ID=". $_POST['ID']." ");

 

This query doesn't work, because updates only the last record.

 

Where is wrong?

 

many thanks  ;)

 

Link to comment
https://forums.phpfreaks.com/topic/220221-update-2-record-same-time/
Share on other sites

My db table  has 2 fields:

ID - Place

1    France

2    Germany

 

My form has 2 text fields:

input name=State1

input name=State2

 

if I digit Italy in inputname=State1 only updates ID 1

if I digit Spain in inputname=State2 only updates ID 2

 

So, my db table will become:

 

ID - Place

1    Italy

2    Spain

Then you have to check whether the input fields are empty... The same with your query

 

Something like:

if ($_POST['State1'] != '')
// query

if ($_POST['State2'] != '')
// query

 

I hope this helps because i still dont get it what you want exactly......

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.