Update several records at the same time
Hey guys,
I have a table called customers, basically this table has a field called "location" thru this field you can sort the route of our agents, with this we can see which is the first customer that we need to visit.
Here is how the table looks
customer number | Name | Agent | Day | Location
1 | php | Agent1 | Monday | 1
2 | asp | agent1 | Monday | 2
3 | php3 |agent1 | Monday | 3
The "Customers" table has that information, I make a query that shows the route of the agent 1 for monday, basically I would like to be able to modify that route, change the location, lets say I want the location 3 become the number 1, and the number 2 become the number 3; I would like to update the three rows,
I made an update thru DreamWeaver this is the code that I got
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE clientes SET UBICACION=%s, NOMBRE=%s, AGENTE=%s, PREVENTA=%s, DISPLAYDIA=%s WHERE CLIENTE=%s",
GetSQLValueString($_POST['ubicaciontabla'], "int"),
GetSQLValueString($_POST['nombretabla'], "text"),
GetSQLValueString($_POST['agentetabla'], "text"),
GetSQLValueString($_POST['preventatabla'], "text"),
GetSQLValueString($_POST['displaytabla'], "text"),
GetSQLValueString($_POST['clientetabla'], "int"));
mysql_select_db($database_servidorenvivo, $servidorenvivo);
$Result1 = mysql_query($updateSQL, $servidorenvivo) or die(mysql_error());
$updateGoTo = "salaagente.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
Should I do this in a loop? Like a foreach, if so I do not know how to do it ![]()
This is how it looks, I would like to edit "Ubicacion, Agente, Preventa and Dia Display".

Is this possible?