change it!!?!
Posted: Mon Nov 07, 2005 6:54 pm
There are two thing that is not working right ...
When i click the button to change a dataset, the script always takes the first one i cant select the second or third.
Also it doesnt change it ... there must be a mistake that i just dont see !!!
PLEASE HELP
When i click the button to change a dataset, the script always takes the first one i cant select the second or third.
Also it doesnt change it ... there must be a mistake that i just dont see !!!
Code: Select all
<html><head><title>Change Dataset</title></head><body>
<?php
error_reporting(E_ALL);
$db = mysql_connect("localhost","root","") or die ("MySQL-Fehler: " . mysql_error());
mysql_select_db("safe",$db) or die ("MySQL-Fehler: " . mysql_error());
$sql = 'SELECT * FROM `sam_artikel`';
$result = mysql_query($sql);
$rows = mysql_num_rows($result);
$cols = mysql_num_fields($result);
echo '<p><b>You have '.$rows.' CDs:</b></p>';
echo '<table border="1"><tr><th>#</th>';
for ($i = 0; $i<$cols; $i++)
{
echo '<th>'.htmlentities(mysql_field_name($result,$i)).'</th>';
}
echo "<th>update?</th>";
echo "</tr>";
for ($i = 0; $i < $rows; $i++)
{
$z = $i+1;
echo "<tr><td>$z</td>";
for ($k = 0; $k < $cols; $k++
{
$cell = mysql_result($result, $i, $k);
echo '<td>'.$cell.'</td>';
}
?>
<td><a href="http://localhost/aendern.php?i=<?php echo $i; ?>">aendern</a></td>
<?php }
mysql_close();
?>
</tr>
</table></body></html>Code: Select all
<html><head><title>Change!</title></head>
<body>
You can now change the selected:<br><br>
<?php
error_reporting(E_ALL);
$db = mysql_connect("localhost","root","") or die ("MySQL-Fehler: " . mysql_error());
mysql_select_db("safe",$db) or die ("MySQL-Fehler: " . mysql_error());
$sql="SELECT * FROM sam_artikel";
$result=mysql_query($sql);
$rows=mysql_num_rows($result);
$cols=mysql_num_fields($result);
echo "<form>";
echo "<table border=1><tr>";
$cell=mysql_result($result,$i=0);
echo "<td>$cell</td>";
for ($k=1;$k<$cols;$k++)
{
$cell=mysql_result($result,$i,$k);
$name=htmlentities(mysql_field_name($result,$k));
echo "<td><input type=\"text\" name=\"$name\" value=\"$cell\"></td>";
}
echo "</tr></table><br>";
?>
<input type="submit" name="update" value="Ändern">
<input type="hidden" name="i" value="<?php echo $i; ?>"><br><br></form>
<?php
$nummer=mysql_result($result,$i,0);
if ($update)
{
mysql_query("UPDATE sam_artikel SET eqdes='$eqdes', designer='$designer', value='$value', beschreibung='$beschreibung', eqdesignation='$eqdesignation' WHERE id='$nummer'");
echo "The CD $nummer was changed";
}
mysql_close();
?>
</body></html>