Query the database first to see if the user has ever taken a test:
$result = mysql_query("SELECT * FROM questions WHERE Name='$name'");
$num = mysql_numrows($result);
//If person does not exist in database, create new entry:
if (!$num){
mysql_query("INSERT INTO questions (Name,A1) VALUES ('$name','$val')");
}
//If person DOES exist in database, update row:
else {
mysql_query("UPDATE questions SET A2='$val' WHERE Name='$name'");
}
You would probably have to have a variable set, perhaps a hidden variable, that determines which column is to be updated in the database (based on which test they took).
This will work, but think about what mrhappiness has said about table design.
Sound ok?
Jamie