Eléphanteau du PHP |
30 Messages
08 févr. 2006, 16:10
Je vais directement poster tout ce qui peut être utile.
D'abord, quelques erreurs -->
- Warning: Invalid argument supplied for foreach() in c:\program files\easyphp1-8\www\tests bd\tests3\suppr.php on line 13
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\tests bd\tests3\default2.php:10) in c:\program files\easyphp1-8\www\tests bd\tests3\suppr.php on line 17
N'y a-t-il pas une formule qui permet de faire une redirection au lieu d'un include ? Ce serait le top !
Sinon, si cela peut aider, voici le code des pages utiles à la modification -->
index_modif.php -->
<?php require_once('Connections/tests_bd.php'); ?>
<?php
mysql_select_db($database_tests_bd, $tests_bd);
$query_Recordset1 = "SELECT eleves.numero, eleves.nom, eleves.prenom FROM eleves ORDER BY eleves.nom, eleves.prenom";
$Recordset1 = mysql_query($query_Recordset1, $tests_bd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
<body>
<a href="index.html">Retour
</a>
<form id="form1" name="form1" method="post" action="default2.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><em><strong>N°</strong></em></td>
<td><em><strong>Nom</strong></em></td>
<td><em><strong>Prénom</strong></em></td>
<td><p><!--
<input name="radio" type="radio" value="choix1" checked="checked" />
modif</p>
<p>
<input type="radio" name="radio" value="choix2" />
suppr-->
</p>
<p>
<input type="submit" name="modif" value="Modif" />
<input type="submit" name="suppr" value="Suppr" />
</p></td>
</tr>
<?php
while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) {
?>
<tr>
<td><?php echo $row_Recordset1['numero']; ?></td>
<td><?php echo $row_Recordset1['nom']; ?></td>
<td><?php echo $row_Recordset1['prenom']; ?></td>
<td><input type="checkbox" name="checkbox[]" value="<?php echo $row_Recordset1['numero']; ?>"/></td>
</tr>
<?php
}
?>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Afficher" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
default2.php -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<?php
if (isset($_POST['modif']) && $_POST['modif'] == "Modif") {
include("modif.php");
}
elseif (isset($_POST['suppr']) && $_POST['suppr'] == "Suppr") {
include("suppr.php");
}
else {}
?>
</form>
</body>
</html>
et modif.php qui est incluse dans default2.php -->
<?php require_once('Connections/tests_bd.php'); ?>
<?php
mysql_select_db($database_tests_bd, $tests_bd);
$query_Recordset1 = "SELECT eleves.numero, eleves.nom, eleves.prenom FROM eleves";
$Recordset1 = mysql_query($query_Recordset1, $tests_bd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php
require_once('Connections/tests_bd.php');
mysql_select_db($database_tests_bd, $tests_bd);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="modifOK.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><em><strong>N°</strong></em></td>
<td><em><strong>Nom</strong></em></td>
<td colspan="2"><em><strong>Prénom</strong></em></td>
</tr>
<?php
if ($_POST["checkbox"])
foreach ($_POST["checkbox"] as $result_numero) {
$query_Recordset1 = "SELECT eleves.numero, eleves.nom, eleves.prenom FROM eleves WHERE eleves.numero = '$result_numero'";
$Recordset1 = mysql_query($query_Recordset1, $tests_bd) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
?>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['numero']; ?></td>
<td><input name="nom[]" type="text" value="<?php echo $row_Recordset1['nom']; ?>" /></td>
<td><input type="text" name="prenom[]" value="<?php echo $row_Recordset1['prenom']; ?>" /></td>
<td><input name="numero[]" type="hidden" value="<?php echo $row_Recordset1['numero']; ?>" /></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
<?php
}
?>
<tr>
<td> </td>
<td> </td>
<td colspan="2"><input type="submit" name="Submit" value="Modifier" /></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
