IF EXISTS UPDATE ELSE INSERT DATA (MYSQL)

Contoh kode PHP
$result = mysql_query("SELECT * FROM $mytable WHERE title_1 ='$title_1' ");

if( mysql_num_rows($result) > 0) {
    mysql_query("UPDATE $mytable SET time = '$time' WHERE title_1 = '$title_1' ");
}
else
{
    mysql_query("INSERT INTO $mytable (title_1) VALUES ('$title_1') ");
}
s
Previous
Next Post »