Hi all, i am hoping i will be able to get some quick help here. Ok i am basically building a web application where the user will be able to add,update,delete and edit fields in a database. So far i am on the Update part.
I have a page called recordmanager.php that displays all rows within a selected table as a table display. The last column on the php i added myself called update where the user can click on the update link to update a specific row. See below: <td align="center"><a href="update.php?id=<?php echo $rows['id']; ?>">Update</a></td>
Now that code works fine because i have the id as a session variable.
Now..when i get to the update.php page, this should display the selected row as text boxes (dynamically) so the user is able to edit it.
<?php
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result4);
?>
<td align="center"><strong><?php echo "{$field->name}"; } ?> </strong></td>
</tr>
<?php
while($row3= mysql_fetch_row($result))
{
echo "<tr>";
echo "<td> </td>";
// $row is array...the foreach( .. )loop puts every element
// of $row into the $cell variable
foreach($row3 as $cell)
//echo "<td>$cell</td>";
echo
"
<td align='center'><input name='cells' type='text' id='name' value='$cell'></td>";
}
?>
the $cell variable is what i am having problems with using. I am trying to use an UPDATE query to update every single text field that the user changes. Now.... i could have easily done this if i didnt do it dynamically but i need a way to do use the UPDATE query to update the table according to the edited text boxes;
<?php
$sql2="UPDATE $Tbselect SET * WHERE arist_id='$id'";
$resultedit=mysql_query($sql2) or die(mysql_error());
if($resultedit){
echo "Update Successful";
echo "<BR>";
echo "<a href='update.php'>Click to refresh and see results</a>";
}
else {
echo "ERROR";
}
?>
The point i am trying to make is that it would be much easier if i did this, for example:
$sql="UPDATE $tbl_name SET name='$name', lastname='$lastname', email='$email' WHERE id='$id'";
$result=mysql_query($sql);
But i cant do that because my fields are dynamic...please help.
Thanks
Maleek