Witam!
Mam dwa pliki. Pierwszy jest do wybierania userów do edytowania a drugi do odbioru zaznaczonych userów i aktualizowania ich. Problem polega na tym że jak wstawię "powtórz region"
to owszem pokazuje zaznaczonych userów ale nie chce ich aktualizować. Gdzie tkwi szczegół. Przy braku "powtórz region" owszem aktualizuje tylko jednego bo wiadomo wyświetli tylko jednego a nie więcej. pliki to edit.php i t1.php Bardziej oczekuje nakierowania w pliku t1.php http://wklej.to/2VaQ0 a tu drugi plik edit.php do zaznaczania http://wklej.to/3oqKz .
pozdrawiam
  1. <?php require_once('../Connections/local.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6. if (PHP_VERSION < 6) {
  7. $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8. }
  9.  
  10. $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12. switch ($theType) {
  13. case "text":
  14. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15. break;
  16. case "long":
  17. case "int":
  18. $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19. break;
  20. case "double":
  21. $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22. break;
  23. case "date":
  24. $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25. break;
  26. case "defined":
  27. $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28. break;
  29. }
  30. return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36. $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  40. $updateSQL = sprintf("UPDATE userlogin SET firstname=%s, lastname=%s, username=%s, password=%s, email=%s WHERE user_id=%s",
  41. GetSQLValueString($_POST['firstname'], "text"),
  42. GetSQLValueString($_POST['lastname'], "text"),
  43. GetSQLValueString($_POST['username'], "text"),
  44. GetSQLValueString($_POST['password'], "text"),
  45. GetSQLValueString($_POST['email'], "text"),
  46. GetSQLValueString($_POST['user_id'], "int"));
  47.  
  48. mysql_select_db($database_local, $local);
  49. $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
  50.  
  51. $updateGoTo = "edit.php";
  52. if (isset($_SERVER['QUERY_STRING'])) {
  53. $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  54. $updateGoTo .= $_SERVER['QUERY_STRING'];
  55. }
  56. header(sprintf("Location: %s", $updateGoTo));
  57. }
  58.  
  59. $maxRows_Recordset1 = 10;
  60. $pageNum_Recordset1 = 0;
  61. if (isset($_GET['pageNum_Recordset1'])) {
  62. $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
  63. }
  64. $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
  65.  
  66. mysql_select_db($database_local, $local);
  67. $query_Recordset1 = "SELECT * FROM userlogin";
  68. $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
  69. $Recordset1 = mysql_query($query_limit_Recordset1, $local) or die(mysql_error());
  70. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  71.  
  72. if (isset($_GET['totalRows_Recordset1'])) {
  73. $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
  74. } else {
  75. $all_Recordset1 = mysql_query($query_Recordset1);
  76. $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
  77. }
  78. $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
  79.  
  80. $colname_Recordset1 = "-1";
  81. if (isset($_POST['user_id'])) {
  82. $colname_Recordset1 = $_POST['user_id'];
  83. }
  84. mysql_select_db($database_local, $local);
  85. $query_Recordset1 = sprintf("SELECT user_id, firstname, lastname, username, password, email FROM userlogin WHERE user_id = %s", GetSQLValueString($colname_Recordset1, "int"));
  86. $query_Recordset1 = sprintf("SELECT * FROM userlogin WHERE user_id = %s", GetSQLValueString($colname_Recordset1, "int"));
  87. $query_Recordset1 = "SELECT user_id, firstname, lastname, username, password,email,dateregister,lastlogin,active FROM userlogin WHERE user_id IN (".implode(',',$_POST['checkbox']).")";
  88. $Recordset1 = mysql_query($query_Recordset1, $local) or die(mysql_error());
  89. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  90. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  91. ?>
  92. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  93. <html xmlns="http://www.w3.org/1999/xhtml">
  94. <head>
  95. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  96. <title>Dokument bez tytułu</title>
  97. </head>
  98.  
  99. <body>
  100. <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  101. <?php do { ?>
  102. <table align="center">
  103. <tr valign="baseline">
  104. <td nowrap="nowrap" align="right">User_id:</td>
  105. <td><?php echo $row_Recordset1['user_id']; ?></td>
  106. </tr>
  107. <tr valign="baseline">
  108. <td nowrap="nowrap" align="right">Firstname:</td>
  109. <td><input type="text" name="firstname" value="<?php echo htmlentities($row_Recordset1['firstname'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  110. </tr>
  111. <tr valign="baseline">
  112. <td nowrap="nowrap" align="right">Lastname:</td>
  113. <td><input type="text" name="lastname" value="<?php echo htmlentities($row_Recordset1['lastname'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  114. </tr>
  115. <tr valign="baseline">
  116. <td nowrap="nowrap" align="right">Username:</td>
  117. <td><input type="text" name="username" value="<?php echo htmlentities($row_Recordset1['username'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  118. </tr>
  119. <tr valign="baseline">
  120. <td nowrap="nowrap" align="right">Password:</td>
  121. <td><input type="text" name="password" value="<?php echo htmlentities($row_Recordset1['password'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  122. </tr>
  123. <tr valign="baseline">
  124. <td nowrap="nowrap" align="right">Email:</td>
  125. <td><input type="text" name="email" value="<?php echo htmlentities($row_Recordset1['email'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
  126. </tr>
  127. <tr valign="baseline">
  128. <td nowrap="nowrap" align="right">&nbsp;</td>
  129. <td><input type="submit" value="Uaktualnij rekord" /></td>
  130. </tr>
  131. </table>
  132. <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
  133. <input type="hidden" name="MM_update" value="form1" />
  134. <input type="hidden" name="user_id" value="<?php echo $row_Recordset1['user_id']; ?>" />
  135. </form>
  136. <p>&nbsp;</p>
  137. </body>
  138. </html>
  139. <?php
  140. mysql_free_result($Recordset1);
  141. ?>
  142.  


Witam.
Czy jest ktos w stanie ten temat ruszyć?
Pozdrawiam