Jump to content

Update query question


acctman

Recommended Posts

looks like i'm going to have to do this the hard way, by posting multiple questions to get this done. From what i'm reading its taking all the from post that have add in them and Updating it into the database. my question is, what if the entry / value doesn't exist in the table already will it perform an insert?

 

 

 

        foreach ($_POST['add'] as $key => $value)

                mysql_query("UPDATE $membtable SET m_".$key."='".sql_escape_string(stripslashes($value))."' WHERE m_id=$id");

Link to comment
https://forums.phpfreaks.com/topic/126636-update-query-question/
Share on other sites

I don't understand your question.  Are you asking if you can INSERT a new ROW if it doesn't exist or UPDATE it if it does?  If so, then what I linked would do it

 

What do you mean by "entry/value" ?  Do you mean a field name or do you mean the data?

I don't understand your question.  Are you asking if you can INSERT a new ROW if it doesn't exist or UPDATE it if it does?  If so, then what I linked would do it

 

What do you mean by "entry/value" ?  Do you mean a field name or do you mean the data?

 

if i don't change the coding below, will a blank field be updated with the form value?

 

foreach ($_POST['add'] as $key => $value)

                mysql_query("UPDATE $membtable SET m_".$key."='".sql_escape_string(stripslashes($value))."' WHERE m_id=$id");

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.