Re: if() and else() help needed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



JeRRy wrote:
Hi,
I'll admit it, this is damned messy. But I want to learn from the list in how to sort it out. Than for future refrence I will know... Now I am running 2 different queries/statements here completely seperate. I have made the "nickname" field in the database UNIQUE. So than when I have this sort of query setup no matter what their will only be one "nickname" entry for that user. So when people update their profile a new "nickname" is not inserted but it is updated. But I want it all in one PHP call. How do I do this?

How are you differentiating between the statements?

eg they are logged in, or you check with a database query or .... ?

You could do something like this:

// check for $_GET['tipid'] - if it's there, we're updating our tips.
// if it's not, then we're adding new tips.
if (isset($_GET['tipid'])) {
  $query = "UPDATE " ......
  $success_message = "Your tips have been updated";
} else {
  $query = "INSERT INTO " .....
  $success_message = "Your tips have been saved";
}

$result = mysql_query($query);
if ($result) {
  echo $success_message;
} else {
  echo "Problem!!<br/>";
}


--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux