Ok, i'm trying to update in the same page but it either comes through as an array or updates one and the rest at the same time.
Can you help?
Here is the code:
<?php
if(isset($_POST['textid']))
{
$id = $_POST['textid'];
$n = count($id);
$i = 0;
$text = $_POST['text'];
echo $text;
while ($i < $n)
{
$ei = "{$id[$i]}";
$i++;
mysql_query ("UPDATE textinput SET text = '$text' WHERE textid = '{$ei}'");
}
}
$result = mysql_query("SELECT * FROM textinput");
echo "<table border='1'><form action='edit.php' method='post'>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['textid'] . "</td>";
echo "<td>";
echo "<input type='text' name='text' value='" . $row['text'] . "'>";
echo "</td>";
echo "<td>";
echo "<input type='hidden' name='textid' value='" . $row['textid'] . "'>";
echo "<td>";
echo "</tr>";
};
echo "<tr>";
echo "<td>";
echo "<input name='send' type='submit' value='EDIT!'>";
echo "</td>";
echo "</tr>";
echo "</form></table>";
?>
</body>
</html>
|