try2phpstuff Posted March 22, 2007 Share Posted March 22, 2007 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. Link to comment https://forums.phpfreaks.com/topic/43876-solved-if-this-happen-dont-do-this-instead-do-this/ Share on other sites More sharing options...
Kerblam Posted March 22, 2007 Share Posted March 22, 2007 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); Link to comment https://forums.phpfreaks.com/topic/43876-solved-if-this-happen-dont-do-this-instead-do-this/#findComment-212987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.