adzie Posted October 27, 2007 Share Posted October 27, 2007 Hi I'm working on a form to be able to edit multiple records at the same time but only the first record is showing the correct details. any thoughts? <?php $title="Vehicle Allocation Sheet"; $title2=$Title."<center>Stats</center></font></u>"; $msg = $Body."<center>"; { $sq2l="UPDATE cars SET reg='".$_POST[reg]."', type='".$_POST['type']."', tail='".$_POST['tail']."', grg='".$_POST['grg']."', mark='".$_POST['mark']."', status='".$_POST['status']."', active=".$_POST['active']."', allocation=".$_POST['allocation']."', nextserv=".$_POST['nextserv']."' where ac_id='".$_POST['id']."'"; if(mysql_query($sql2,$conn)) { $msg.=$Body."Database updated successfully<br><a href=index.php?page=management&managementpage=users&use=view>Click here edit Again</a><br> <br><a href=admin.php>".$Body."Admin page</font></u></b></a><br> <a href=index.php>".$Body."Home</font></u></b></a><br>"; } $sql="select * from cars where grg=3 order by tail ASC"; $query = mysql_query($sql); $msg.= "<center><img src=images/avatars/car.gif>"; $msg .= "<table border=1 align=center><tr><td><strong>Allocation</strong></td><td><strong>Tail</strong></td><td><strong>Reg</strong></td><td><strong>Type</strong></td><td><strong>Mark</strong></td><td><strong>Hours</strong></td><td><strong>Status</strong></td><td><strong>Next Service</strong></td></tr>"; while($row = mysql_fetch_row($query)) { $query_hours = "SELECT sec_to_time(sum(time_to_sec(t2.duration))) AS duration_sum FROM carst1, car_reports t2 WHERE t1.reg=\"".$row[5]."\" AND t1.reg=t2.cars"; $result_hours = mysql_query($query_hours); if (mysql_numrows($result_hours) > 0) { $time = mysql_result($result_hours,0,"duration_sum"); } { if($row['10'] == 0) { $UnServiceable = "selected"; } elseif($row['10'] == 1) { $Serviceable = "selected"; } if($row['12'] == 0) { $Minor = "selected"; } elseif($row['12'] == 1) { $Major = "selected"; } elseif($row['12'] == 2) { $Minorstar = "selected"; } $msg .= "<tr align=center><td><input type=\"text\" name=\"allocation\" value=\"".$row['11']."\"></td><td><strong>".$row['6']."</strong></td><td>".$row['5']."</td><td>".$row['1']."</td><td>".$row['2']."</td><td>".$time."</td> <td><select name=\"".$row['10']."\"><option value=0 ".$UnServiceable.">UnServiceable</option><option value=1 ".$Serviceable.">Serviceable</option></select> <td><select name=\"".$row['12']."\"><option value=0 ".$Minor.">Minor</option><option value=1 ".$Major.">Major</option><option value=2 ".$Minorstar.">Minor Star</option></select><td>".$row['10']."</td><td>".$row['12']."</td></tr>"; } } $msg.="</table>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/74989-mulitple-record-form-edit/ Share on other sites More sharing options...
MadTechie Posted October 27, 2007 Share Posted October 27, 2007 My first thought, is can you use code tags [.code][/.code] (without the dots) as its a pain to read the code otherwise second thought, your using where ac_id='".$_POST['id']."'" thus it will only update that id.. can we see the form.. code below is unchanged but eaiser to read for anyone else <?php $title="Vehicle Allocation Sheet"; $title2=$Title."<center>Stats</center></font></u>"; $msg = $Body."<center>"; { $sq2l="UPDATE cars SET reg='".$_POST[reg]."', type='".$_POST['type']."', tail='".$_POST['tail']."', grg='".$_POST['grg']."', mark='".$_POST['mark']."', status='".$_POST['status']."', active=".$_POST['active']."', allocation=".$_POST['allocation']."', nextserv=".$_POST['nextserv']."' where ac_id='".$_POST['id']."'"; if(mysql_query($sql2,$conn)) { $msg.=$Body."Database updated successfully<br><a href=index.php?page=management&managementpage=users&use=view>Click here edit Again</a><br> <br><a href=admin.php>".$Body."Admin page</font></u></b></a><br> <a href=index.php>".$Body."Home</font></u></b></a><br>"; } $sql="select * from cars where grg=3 order by tail ASC"; $query = mysql_query($sql); $msg.= "<center><img src=images/avatars/car.gif>"; $msg .= "<table border=1 align=center><tr><td><strong>Allocation</strong></td><td><strong>Tail</strong></td><td><strong>Reg</strong></td><td><strong>Type</strong></td><td><strong>Mark</strong></td><td><strong>Hours</strong></td><td><strong>Status</strong></td><td><strong>Next Service</strong></td></tr>"; while($row = mysql_fetch_row($query)) { $query_hours = "SELECT sec_to_time(sum(time_to_sec(t2.duration))) AS duration_sum FROM carst1, car_reports t2 WHERE t1.reg=\"".$row[5]."\" AND t1.reg=t2.cars"; $result_hours = mysql_query($query_hours); if (mysql_numrows($result_hours) > 0) { $time = mysql_result($result_hours,0,"duration_sum"); } { if($row['10'] == 0) { $UnServiceable = "selected"; } elseif($row['10'] == 1) { $Serviceable = "selected"; } if($row['12'] == 0) { $Minor = "selected"; } elseif($row['12'] == 1) { $Major = "selected"; } elseif($row['12'] == 2) { $Minorstar = "selected"; } $msg .= "<tr align=center><td><input type=\"text\" name=\"allocation\" value=\"".$row['11']."\"></td><td><strong>".$row['6']."</strong></td><td>".$row['5']."</td><td>".$row['1']."</td><td>".$row['2']."</td><td>".$time."</td> <td><select name=\"".$row['10']."\"><option value=0 ".$UnServiceable.">UnServiceable</option><option value=1 ".$Serviceable.">Serviceable</option></select> <td><select name=\"".$row['12']."\"><option value=0 ".$Minor.">Minor</option><option value=1 ".$Major.">Major</option><option value=2 ".$Minorstar.">Minor Star</option></select><td>".$row['10']."</td><td>".$row['12']."</td></tr>"; } } $msg.="</table>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/74989-mulitple-record-form-edit/#findComment-379218 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.