What I want to do is, after inserting a new member, it will update the other member used in referral.
Inserting works, but updating doesnt…
[php]if ((isset($_POST[“MM_insert”])) && ($_POST[“MM_insert”] == “contact”)) {
$insertSQL = sprintf(“INSERT INTO Members (FirstName, LastName, Gender, Referral, Level, Cash, Status) VALUES (%s, %s, %s, %s, ‘$x’, ‘$y’, ‘$z’)”,
GetSQLValueString($_POST[‘txtFName’], “text”),
GetSQLValueString($_POST[‘txtLName’], “text”),
GetSQLValueString($_POST[‘txtGender’], “text”),
GetSQLValueString($_POST[‘txtReferral’], “text”));
mysql_select_db($database_PMSmetro, $PMSmetro);
$Result1 = mysql_query($insertSQL, $PMSmetro) or die(mysql_error());
$insertGoTo = “index.php”;
if (isset($_SERVER[‘QUERY_STRING’])) {
$insertGoTo .= (strpos($insertGoTo, ‘?’)) ? “&” : “?”;
$insertGoTo .= $_SERVER[‘QUERY_STRING’];
}
header(sprintf(“Location: %s”, $insertGoTo));
}
if ((isset($_POST[“MM_update”])) && ($_POST[“MM_update”] == “contact”)) {
mysql_select_db($database_PMSmetro, $PMSmetro);
$query_rsMembers = “SELECT concat(LastName, ', ’ , FirstName) AS name FROM Members WHERE FirstName = ‘Aldrin’”;
$rsMembers = mysql_query($query_rsMembers, $PMSmetro) or die(mysql_error());
$row_rsMembers = mysql_fetch_assoc($rsMembers);
$totalRows_rsMembers = mysql_num_rows($rsMembers);mysql_select_db($database_PMSmetro, $PMSmetro);
$LastN=$row_rsMembers[‘LastName’];
$FirstN=$row_rsMembers[‘FirstName’];
$CCash=$row_rsMembers[‘Cash’]+50;
$FullN=$row_rsMembers[‘name’];
$updateSQL = sprintf(“UPDATE Members SET Cash=’”. $CCash . “’, Level2=’”. $FullN . “’ WHERE FirstName=’”.$FirstN."’ AND LastName=’".$LastN."’");
mysql_select_db($database_PMSmetro, $PMSmetro);
$Result1 = mysql_query($updateSQL, $PMSmetro) or die(mysql_error());
$updateGoTo = “index.php”;
if (isset($_SERVER[‘QUERY_STRING’])) {
$updateGoTo .= (strpos($updateGoTo, ‘?’)) ? “&” : “?”;
$updateGoTo .= $_SERVER[‘QUERY_STRING’];
}
header(sprintf(“Location: %s”, $updateGoTo));
}
[/php]