Jump to content

[SOLVED] if no update do insert


dennismonsewicz

Recommended Posts

here is a simple check. Lets say we want to check to see if a username exists

<?php
$user= $_POST['username'];
$check = "SELECT `username` FROM `users` WHERE `username` = '$user'";
$result = mysql_query($check) or die(mysql_error());
$found = mysql_num_rows($result);
if($found > 0){
// update query below

} else {
// Insert Query below

}
?>

 

Ray

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.