Jump to content

[SOLVED] if this happen dont do this, instead do this


try2phpstuff

Recommended Posts

i have a script that i want to INSERT if they initially submit, or Update if they Submit with a different value like if (isset($_POST['submit'])) or if (isset($_POST['update'])), but i don't want to have to add all of the same info to the script, i just want to change the query that gets sent each time.

Well the best logical way to do this is by storing the query as a variable, and choosing which one to use based on the input. For example:

if (isset($_POST['submit'])) {
  
  $query = "INSERT blah blah blah";
  
} else {
  
  $query = "UPDATE blah blah blah";
}

$result = @mysql_query($query);

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.