Jump to content

[SOLVED] oh noes: my update button does nothing


andrewtwice

Recommended Posts

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  :P

 

Link to comment
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.