Skip to main content
Known Participant
March 18, 2011
Question

Update several records at the same time

  • March 18, 2011
  • 1 reply
  • 984 views

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".

http://lanacionalsa.com/aplicaciones/rutas/ruta.png

Is this possible?

This topic has been closed for replies.

1 reply

pelonms7Author
Known Participant
March 19, 2011

Does someone knows how to do this?

Günter_Schenk
Inspiring
March 19, 2011

I think you should try with this tutorial and adapt it to make it work with Dreamweaver´s Update Record workflow.

Hint: googling "dreamweaver php update multiple" will reveal lots of other tutorials or "how can I..." forum post, although most results will not be Dreamweaver specifc.

pelonms7Author
Known Participant
March 21, 2011

Thanks a lot man, I will give it a try