andrewtwice Posted December 31, 2007 Author Share Posted December 31, 2007 it still does not update. i dont know what to suggest next... rajiv you have been more than helpful, i don't blame you if you give up at any time Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426541 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 make $sql1 = "UPDATE $tbl_name SET adnum='{$adnum[$i]}',acct='{$acct[$i]}',size='{$size[$i]}',rundate='{$rundate[$i]}',rep='{$rep[$i]}',comments='{$comments[$i]}',inprogress='{$inprogress[$i]}',waitcopy='{$waitcopy[$i]}', outproof='{$outproof[$i]}',camready='{$camready[$i]}' WHERE id='{$id[$i]}'"; to $sql1 = "UPDATE $tbl_name SET adnum='{$adnum[$i]}',acct='{$acct[$i]}',size='{$size[$i]}',rundate='{$rundate[$i]}',rep='{$rep[$i]}',comments='{$comments[$i]}',inprogress='{$inprogress[$i]}',waitcopy='{$waitcopy[$i]}', outproof='{$outproof[$i]}',camready='{$camready[$i]}' WHERE id='{$id[$i]}'"; echo $sql1."<BR>"; and tell me the update statements are echoed on submit... the problem is I do not have any place to test the code Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426544 Share on other sites More sharing options...
andrewtwice Posted December 31, 2007 Author Share Posted December 31, 2007 http://andrewhusband.homelinux.net/adscape/clean2.php Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426548 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 Lolzz.. got it your update statement should be $sql1 = "UPDATE $tbl_name SET adnum='{$_POST['adnum'][$i]}',acct='{$_POST['acct'][$i]}',size='{$_POST['size'][$i]}',rundate='{$_POST['rundate'][$i]}',rep='{$_POST['rep'][$i]}',comments='{$_POST['comments'][$i]}',inprogress='{$_POST['inprogress'][$i]}',waitcopy='{$_POST['waitcopy'][$i]}', outproof='{$_POST['outproof'][$i]}',camready='{$_POST['camready'][$i]}' WHERE id='{$_POST['id'][$i]}'"; Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426549 Share on other sites More sharing options...
andrewtwice Posted December 31, 2007 Author Share Posted December 31, 2007 no luck. i took out the echo string but it didn't make a difference. you can check the url again its the one im updating as you give me code. Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426554 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 post your full code again ... you might of missed something out.. Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426557 Share on other sites More sharing options...
andrewtwice Posted December 31, 2007 Author Share Posted December 31, 2007 alright: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body bgcolor="white" text="black" link="blue" vlink="purple"> <?php $host="localhost"; $username="root"; $password=""; $db_name="ads"; $tbl_name="rop"; if(mysql_connect("$host", "$username", "$password")) { if(mysql_select_db("$db_name")) { $count = count($_POST['id']); if(isset($_POST['Submit'])) { // Database update code for($i=0;$i<$count;$i++){ $sql1 = "UPDATE $tbl_name SET adnum='{$_POST['adnum'][$i]}',acct='{$_POST['acct'][$i]}',size='{$_POST['size'][$i]}',rundate='{$_POST['rundate'][$i]}',rep='{$_POST['rep'][$i]}',comments='{$_POST['comments'][$i]}',inprogress='{$_POST['inprogress'][$i]}',waitcopy='{$_POST['waitcopy'][$i]}', outproof='{$_POST['outproof'][$i]}',camready='{$_POST['camready'][$i]}' WHERE id='{$_POST['id'][$i]}'"; echo $sql1."<BR>"; $result1=mysql_query($sql1); } } $sql = "SELECT * FROM $tbl_name"; $result = mysql_query($sql); // Form goes here print '<table width="500" border="0" cellspacing="1" cellpadding="0">'; print '<form name="form1" method="post" action="' . $_SERVER['PHP_SELF'] . '">'; print '<tr>'; print '<td>'; print '<table width="500" border="0" cellspacing="1" cellpadding="0">'; print '<tr>'; print '<td align="center"><strong>Ad #:</strong></td>'; print '<td align="center"><strong>Account:</strong></td>'; print '<td align="center"><strong>Size:</strong></td>'; print '<td align="center"><strong>Run Date:</strong></td>'; print '<td align="center"><strong>Rep:</strong></td>'; print '<td align="center"><strong>Comments:</strong></td>'; print '<td align="center"><strong>Pickup:</strong></td>'; print '<td align="center"><strong>Waitcopy:</strong></td>'; print '<td align="center"><strong>Out on Proof:</strong></td>'; print '<td align="center"><strong>Camera Ready:</strong></td>'; print '</tr>'; while($rows=mysql_fetch_array($result)){ print '<tr>'; print '<td align="center"><input type="hidden" name="id[]" value="' . $rows['id'] . '">' . $rows['id'] . '</td>'; print '<td align="center"><input name="adnum[]" type="text" id="adnum" value="' . $rows['adnum'] . '"></td>'; print '<td align="center"><input name="acct[]" type="text" id="acct" value="' . $rows['acct'] . '"></td>'; print '<td align="center"><input name="size[]" type="text" id="size" value="' . $rows['size'] . '"></td>'; print '<td align="center"><input name="rundate[]" type="text" id="rundate" value="' . $rows['rundate'] . '"></td>'; print '<td align="center"><input name="rep[]" type="text" id="rep" value="' . $rows['rep'] . '"></td>'; print '<td align="center"><input name="comments[]" type="text" id="comments" value="' . $rows['comments'] . '"></td>'; print '<td align="center"><input name="inprogress[]" type="checkbox" id="inprogress" value="' . $rows['inprogress'] . '"></td>'; print '<td align="center"><input name="waitcopy[]" type="checkbox" id="waitcopy" value="' . $rows['waitcopy'] . '"></td>'; print '<td align="center"><input name="outproof[]" type="checkbox" id="outproof" value="' . $rows['outproof'] . '"></td>'; print '<td align="center"><input name="camready[]" type="checkbox" id="camready" value="' . $rows['camready'] . '"></td>'; print '</tr>'; } print '<tr>'; print '<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>'; print '</tr>'; print '</table>'; print '</td>'; print '</tr>'; print '</form>'; print '</table>'; if($result1){ header("location:clean2.php"); } } else { print mysql_error(); } mysql_close(); } else { print mysql_error(); } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426562 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 it seems that your row['id'] is not coming in is it there in the database ? Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426564 Share on other sites More sharing options...
andrewtwice Posted December 31, 2007 Author Share Posted December 31, 2007 the id i thought was supposed to be the ad number? <img src="http://i41.photobucket.com/albums/e270/andrewtwice/screenshot.jpg"> Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426566 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 looks like you don't have an id field in the db ?.. maybe you should add one.. Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426568 Share on other sites More sharing options...
andrewtwice Posted December 31, 2007 Author Share Posted December 31, 2007 ok i added the id field. this is so complicated! how do you know how to do everything! :D Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426569 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 what did you add the id as you should of alter table `rop` add id int(11) auto_increment primary key; Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426572 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 do that and your code should start working !!! Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426573 Share on other sites More sharing options...
andrewtwice Posted December 31, 2007 Author Share Posted December 31, 2007 RAJIV IT WORKS!!!!! thank you sooo soo much! ;D i needed this for work tomorrow and was worried i wasn't going to have it ready. thanks again for helping me out. i really appreciate it. Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426575 Share on other sites More sharing options...
rajivgonsalves Posted December 31, 2007 Share Posted December 31, 2007 Always welcome.. Glad to be of help Link to comment https://forums.phpfreaks.com/topic/83802-solved-oh-noes-my-update-button-does-nothing/page/2/#findComment-426577 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.