'view_act.php' file
<?php
$query = mysql_query('select * from activities');
$check=mysql_num_rows($query);
if($check==0)
{
echo "No enteries found ";
}
else
{
static $counter;
echo '<table border="1" cellpadding="5" cellspacing="5" align="center">
<tr>
<th><font color="#FF9900">ACTIVITY NAME</font></th>
<th><font color="#FF9900">ACTIVITY UPDATE</font></th>
</tr>';
while($row=mysql_fetch_array($query))
{ $counter++;
echo '<tr>';
echo '<td width=231>
<form action="update_act.php" method="POST">';
echo "<center><font color=\"#CC9900\">".$row['act_name']."</center>";
echo "</td>
<td width=231>";
echo "<center>".'<font color="#CCCCCC"><input type="submit" name="edit" value="edit"></center>';
echo '<input type="hidden" name="act_name'.$counter.'" value="'.$row['act_name'].'" />';
echo '<input type="hidden" name="count" value="'.$counter.'" />';
echo "</td>
</tr>";
}
echo "</form>";
echo "</table>";
}
?>
'update_act.php' file
<?php
$count=$_POST['count'];
echo "Old Activity Name : ". $_POST["act_name".$count];
echo '<br/>Enter new activity name :
<form action="update_act.php" method="post">
<input type="text" name="aname">
<input type="submit" name="submit">';
?>
Here, the data obtained from the table should be updated using a different name of the edit button, so for each activity name a different name is indicated by the counter. But the problem here is when the form is submitted to the update_act.php page. the value of the last name of the Activity is passed each time. So the value of the old name Activity for any row is the last value of the table "act_name". Please help me pass the appropriate counter value for any activity name.
source
share