tyhoerr Posted July 30, 2009 Share Posted July 30, 2009 I'm trying to design a page that allows a user to edit multiple cells of data in a mysql table and submit them all together. If you've edited multiple entries with phpmyadmin- pretty much the exact same thing as that (except to edit only one column of all the entries, instead of all the the columns of information). I want it to be designed for quick editing: the person who will be using it does it in Excel, and I'd like to be able to make this page work much like it (enter info, tab down to the next row, enter info, tab down again and eventually hitting submit will save all the newly entered data) The problem I have is that instead of saving all the new information, all it does is takes the last submitted field information and saves that data over ALL the other fields. I also attached a screenshot of what it looks like in browser if that helps. How can I get it to save each uniquely modified piece of data to it's respective location? I've tried multiple things over the past week and have still come up empty. Here's the code I've written to try and accomplish it: <?php // CONNECT BEGIN mysql_connect("localhost","****","****"); mysql_select_db("NPD"); // CONNECT END $Size_update=$_POST["Size_$ID"]; $ID_update=$_POST["ID_$ID"]; if(!empty($Size_update)) { $sql3 = "select ID from Child_Table"; $result3 = mysql_query("$sql3") or die('Error, query failed'); while($r3=mysql_fetch_array($result3)) { $ID=$r3["ID"]; $Size_update=$_POST["Size_$ID"]; $ID_update=$_POST["ID_$ID"]; $update = "UPDATE Child_Table SET Size='$Size_update' WHERE ID='$ID_update'"; mysql_query("$update") or die(mysql_error("There was an error")); }} $color1="cccccc"; $color2="ffffff"; $row_count = 0; echo "<form method=\"Post\"><table width=\"100%\" border=\"0\" cellpadding=\"4\" cellspacing=\"0\"><tr><td></td> <td width=\"19%\"><h2>ID</h2></td> <td width=\"19%\"><h2>Size</h2></td> <td width=\"19%\"><h2>Quantity</h2></td> <td width=\"19%\"><h2>BB Price</h2></td> <td width=\"19%\"><h2>IG Price</h2></td></tr>"; $sql = "select * from Child_Table order by PID"; $result = mysql_query("$sql") or die('Error, query failed'); // SEARCH QUERY END // DISPLAY RESULTS BEGIN while($r=mysql_fetch_array($result)) { $ID=$r["ID"]; $PID=$r["PID"]; $Size=$r["Size"]; $Quantity=$r["Quantity"]; $BB_Price=$r["BB_Price"]; $IG_Price=$r["IG_Price"]; $row_color = ($row_count % 2) ? $color1 : $color2; echo "<tr onmouseover=\"style.fontWeight = 'bold'\" onmouseout=\"style.fontWeight = 'normal'\"><td><a href=\"javascript:if(confirm('Are you sure you want to delete $Username?')) self.location='list.php?delete=$Username';\"><img border=\"0\" src=\"delete.jpg\" /></a></td> <td width=\"%19\" bgcolor=\"#$row_color\" nowrap>$PID</td><td width=\"%19\" bgcolor=\"#$row_color\"><input type=\"hidden\" name=\"ID_$ID\" id=\"ID_$ID\" value=\"$ID\"/><input name=\"Size_$ID\" id=\"Size_$ID\" value=\"$Size\"/></td><td width=\"%19\" bgcolor=\"#$row_color\">$Quantity</td><td width=\"%19\" bgcolor=\"#$row_color\">$BB_Price</td><td width=\"%19\" bgcolor=\"#$row_color\">$IG_Price</td></tr>"; $row_count++; } echo "</table><input type=\"Submit\"/></form>"; // DISPLAY RESULTS END echo "<br><br>"; ?> Thanks for any help! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/168170-submitting-modifications-to-multiple-cells/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.