I have a script that creates a record in MySql database which allocates certain machines to any or all of six usergroups under the management of a unique manager. It works fine in creating an original record, but I want to be able to use the same form to update by overwriting the original record, but what I've got just creates a new record each time it is used. Where am I going wrong?

$query = mysql_query("SELECT equip FROM topics WHERE equip = '$equip' AND managerId = '$userid'");
if (mysql_num_rows($query) > 0) {
mysql_query("UPDATE topics SET egroup1 = '$egroup1', egroup2 = '$egroup2', egroup3 = '$egroup3', egroup4 = '$egroup4', egroup5 = '$egroup5', egroup6 = '$egroup6',      WHERE equip = '$equip' AND managerId = '$userid'");
} else {
mysql_query("INSERT INTO topics (managerId, equip, title, url_big, url_small, egroup1, egroup2, egroup3, egroup4, egroup5, egroup6) 
    VALUES ('$userid','$wordquip', '$equip', '$bigpic', '$smallpic', '$egroup1', '$egroup2', '$egroup3', '$egroup4', '$egroup5', '$egroup6')");
6 Years
Discussion Span
Last Post by ayooshkasmth
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.