Learning Mysql and Having a Pile of Questions ...
I can achieve the desired effect by simple:
$mysqli->query("INSERT results SET user_id = '".$user_data[0]['user_id']."', logo_id = '".$mysqli->real_escape_string($_GET['logo_id'])."'");
$mysqli->query("UPDATE results SET result_tries = result_tries +1 WHERE logo_id = '".$mysqli->real_escape_string($_GET['logo_id'])."' AND user_id = '".$user_data[0]['user_id']."'");
I have a DB unique checkin the table, so logo_id and user_id must be unique. So if the line exists, the first request fails, and the second update is executed ... But this seems like a hack ... Is there a better way to do this?
user796443
source
share