andrewtwice
Members-
Posts
18 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
andrewtwice's Achievements
Newbie (1/5)
0
Reputation
-
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
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. -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
ok i added the id field. this is so complicated! how do you know how to do everything! :D -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
the id i thought was supposed to be the ad number? <img src="http://i41.photobucket.com/albums/e270/andrewtwice/screenshot.jpg"> -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
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> -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
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. -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
http://andrewhusband.homelinux.net/adscape/clean2.php -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
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 -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
k trying... -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
rajiv you are my hero. -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
here you can see what it's doing: if you change something then hit submit it just changes it back. -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
cool now it isn't throwing any errors but it still won't update. wow this is becoming really stressful! ??? -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
lol now it says line 24 instead of 23... looks like this now: $sql1 = "UPDATE $tbl_name SET "; $sql1 .= "adnum='" . $adnum[$i] . "',; $sql1 .= "acct='" . $acct[$i] . "',; $sql1 .= "size='" . $size[$i] . "',; $sql1 .= "rundate='" . $rundate[$i] . "',; $sql1 .= "rep='" . $rep[$i] . "',; $sql1 .= "comments='" . $comments[$i] . "',; $sql1 .= "inprogress='" . $inprogress[$i] . "',; $sql1 .= "waitcopy='" . $waitcopy[$i] . "',; $sql1 .= "outproof='" . $outproof[$i] . "',; $sql1 .= "camready='" . $camready[$i] . "',; $sql1 .= "WHERE id='" . $id[$i] . "'"; $result1=mysql_query($sql1); -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
mr_mind: will do, brb to test rajiv: i'm trying that one in the other script... thanks for the syntax -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
wow!! thank you for all that work! ...unfortunately it says Parse error: syntax error, unexpected T_VARIABLE on line 23. which is: $sql1 .= "adnum='" . $adnum[$i] . "', -
[SOLVED] oh noes: my update button does nothing
andrewtwice replied to andrewtwice's topic in PHP Coding Help
hrm. it still isn't working... i understand what you mean about getting things in order, the script makes more sense to me and probably the parser too. the code now looks like this: *note where i commented inside about maybe printing instead of closing php tag around form element? <?php $host="localhost"; $username="root"; $password=""; $db_name="ads"; $tbl_name="rop"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <?php if(isset($_POST['submit'])) { // Database update code // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $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]"; $result1=mysql_query($sql1); } } } else { // Form goes here ?> //I just closed php here because i got an error about an unexpected < //because otherwise i'd have to print it inside the phptag. how do i do that? <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Ad #:</strong></td> <td align="center"><strong>Account:</strong></td> <td align="center"><strong>Size:</strong></td> <td align="center"><strong>Run Date:</strong></td> <td align="center"><strong>Rep:</strong></td> <td align="center"><strong>Comments:</strong></td> <td align="center"><strong>Pickup:</strong></td> <td align="center"><strong>Waitcopy:</strong></td> <td align="center"><strong>Out on Proof:</strong></td> <td align="center"><strong>Camera Ready:</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ ?> <tr> <td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td> <td align="center"><input name="adnum[]" type="text" id="adnum" value="<? echo $rows['adnum']; ?>"></td> <td align="center"><input name="acct[]" type="text" id="acct" value="<? echo $rows['acct']; ?>"></td> <td align="center"><input name="size[]" type="text" id="size" value="<? echo $rows['size']; ?>"></td> <td align="center"><input name="rundate[]" type="text" id="rundate" value="<? echo $rows['rundate']; ?>"></td> <td align="center"><input name="rep[]" type="text" id="rep" value="<? echo $rows['rep']; ?>"></td> <td align="center"><input name="comments[]" type="text" id="comments" value="<? echo $rows['comments']; ?>"></td> <td align="center"><input name="inprogress[]" type="checkbox" id="inprogress" value="<? echo $rows['inprogress']; ?>"></td> <td align="center"><input name="waitcopy[]" type="checkbox" id="waitcopy" value="<? echo $rows['waitcopy']; ?>"></td> <td align="center"><input name="outproof[]" type="checkbox" id="outproof" value="<? echo $rows['outproof']; ?>"></td> <td align="center"><input name="camready[]" type="checkbox" id="camready" value="<? echo $rows['camready']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php } if($result1){ header("location:theirs2.php"); } mysql_close(); ?> </body> </html>