Jump to content

Recommended Posts

One way to do this would be to search for a match for the username.  If a match exists, UPDATE.  If a match does not exist, INSERT.

 

$usernamematch = "Carbon";
$result = $connection->prepare("SELECT username FROM tablename WHERE username = ?");
$result->bind_param("s", $username);
$result->execute();
$result->bind_result($usernamefound);
while ($row = $result->fetch()) {
    
}
if ($usernamefound != "") {

} else {

}

Just seen something else, the update function isn't what I was looking for I don't think, I have a program and I want to keep stats of users in a database for uses such as highscores and dynamic images, so for example, page is:

 

update.php?user=usernamehere&credits=2000&time=00:30:00

 

What I want it todo is if it isn't a duplicate username then it will insert if not it will add the credits gained onto what is currently there, same with time ran (in hh:mm:ss format)

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.