I have two column name
varchar and area
text
name area
abc 12a
dfg test
Now I want to update each of them from my page where I input some text to the textarea fetched from tow rows.
<?
if(isset($_POST['submit'])) {
$i = 0;
foreach($_POST['txt'] as $textarea) {
@$val[$i] = $val[$i].$textarea;
$i++;
}
foreach($val as $value){
$q= mysql_query("UPDATE table_name SET name = '$value' WHERE `area` = '??'");
echo "Success"; }
$sql="select * from table_name";
$res=mysql_query($sql);
?>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table border="1">
<thead>
<tr>
<th>NAME</th>
<th>AREA</th>
</tr>
<?php while($row=mysql_fetch_assoc($res))
{
?>
<tr>
<td><?php echo $row['name']; ?></td>
<td><textarea rows="4" cols="40" name="txt[]"><?php echo $row['area']; ?> </textarea><br/>
</td>
</tr>
<tr>
</tr>
<?php } ?>
<tr>
<td><input type="submit" name="submit" id="submit" value="Update" /></td>
</tr>
</table>
</form>
I am getting the name but could not update/insert it in area
for that name. How do I accomplish this?