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>&nbsp;</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

http://www.millstream.com.au/view/code/tablekit/
In this given link very useful code is there but i have little query if i want the sum of all input field for cost which is outside of the table and which contain sum of cost from all tr and if i update any cell of cost it automaticaly upadte the cost from input filed. If any body knows answer for these please help me...

thanks and advance.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.