Bonjour,

J'ai un problème pour faire passer une variable d'un champ "hidden" d'une région répétée à une autre page.

Dans ma première page "test_31" je liste le contenu d'une table dans la région répétée. Pour chaque élément j'ai intégré un bouton "Go" qui lorsque je clique dessus doit me permettre de passer l' "id_niv31" vers la page "test_32" et me permettre d'y afficher uniquement le record qui correspond à l' "id_niv31".

Le problème est que lorsque je choisis, dans la région répétée de ma première page "test_31" un des trois records contenus dans ma BDD, il me passe toujours la même valeur de l' "id_niv31" dans la seconde page, donc impossible d'afficher avec ma requête le record correspondant.

J'ai trouvé un post de 2007 présentant le même problème, j'ai tenté de suivre exactement la même procédure, mais cela ne fonctionne pas, merci donc d'avance pour vos suggestions!

code 1ère page "test_31"

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<form id="form2" name="form2" method="post" action="test.php">
  <table width="100%" border="0">
    <tr>
      <td>Id_niv31</td>
      <td>Id_niv12:</td>
      <td>Nosprog:</td>
      <td>Nomsprog:</td>
      <td>Objsprog:</td>
      <td>Dotasprog:</td>
      <td>Go:</td>
    </tr><?php do { ?>
    <tr>
      <td><?php echo $row_r_niveau_31['id_niv31']; ?></td>
      <td><?php echo $row_r_niveau_31['id_niv12']; ?></td>
      <td><?php echo $row_r_niveau_31['nosprog']; ?></td>
      <td><?php echo $row_r_niveau_31['nomsprog']; ?></td>
      <td><?php echo $row_r_niveau_31['objsprog']; ?></td>
      <td><?php echo $row_r_niveau_31['dotasprog']; ?></td>
      <td><input name="id_niv31" type="hidden" value="<?php echo $row_r_niveau_31['id_niv31']; ?>" /><input name="Go" type="submit" value="Submit"/>
        </td>
      <?php } while ($row_r_niveau_31 = mysql_fetch_assoc($r_niveau_31)); ?>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>
Code seconde page "test_32"
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php require_once('../Connections/gestion_if.php'); ?>
<?php 
$id_niv31 = $_POST["id_niv31"];
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_r_niveau_31 = "-1";
if (isset($_POST['$id_niv31'])) {
  $colname_r_niveau_31 = $_POST['$id_niv31'];
}
mysql_select_db($database_gestion_if, $gestion_if);
$query_r_niveau_31 = sprintf("SELECT * FROM niveau_31 WHERE id_niv31 = %s", GetSQLValueString($colname_r_niveau_31, "int"));
$r_niveau_31 = mysql_query($query_r_niveau_31, $gestion_if) or die(mysql_error());
$row_r_niveau_31 = mysql_fetch_assoc($r_niveau_31);
$totalRows_r_niveau_31 = mysql_num_rows($r_niveau_31);
?>
<?php
print_r($_POST);
?> 
<?php
mysql_free_result($r_niveau_31);
?>