Vitesse
08-08-2005, 09:18 AM
Would someone be able to just check my code here and see where i've gone wrong.
$query=" SELECT * FROM quartertime WHERE user='$user'"; //Query the DB to check if user exists
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($result !=0){ //if record already exists
//amend it
} else {
// Create new record
}
//Rest of script
Basically i just want to see if one or more records exist that match a username held in $user
the if/else is so if the record exists it amends all records with 'user'=$user
otherwise it makes a new record with their details. The code for adding/amending is already done and working just cant get the If/Else right
Many thanks
$query=" SELECT * FROM quartertime WHERE user='$user'"; //Query the DB to check if user exists
$result=mysql_query($query);
$num=mysql_numrows($result);
if ($result !=0){ //if record already exists
//amend it
} else {
// Create new record
}
//Rest of script
Basically i just want to see if one or more records exist that match a username held in $user
the if/else is so if the record exists it amends all records with 'user'=$user
otherwise it makes a new record with their details. The code for adding/amending is already done and working just cant get the If/Else right
Many thanks