[PHP] Arrays/forms/Loops/Persist (was Re: [PHP] UPDATE syntax)
Ok, I found out why the UPDATE on the table wasn't working. I wasn't giving the command a 'fake' value for the ID column. Ok here is the senario. I have a form which dumps data to cols 1,2,3,5 in a table (thats good). I have another script which runs a loop on the data into another form where I have a textarea, and a checkbox which fills in col 4 and modifies col 5. What I need to do is when the new form submits, to pass the textarea, checkbox ID so I could issue a proper UPDATE. Im able to get it to echo the textarea the checkbox, but no luck with the ID. When the new form is displayed I have the loop echo the ID, but I cant figure out how to submit the ID array. // Snip of problem area (Hope it doesn't look sloppy in the message)// echo form action=\$PHP_SELF?op=reply\ method=\POST\ enctype=\multipart/form-data\\n; $c = 0; while($query_data = mysql_fetch_row($result)) { echo table width=\100%\ cellspacing=\2\ border=\1\ cellpadding=\2\ BGCOLOR=\CC\trtd width=\50%\ valign=\top\\n; echo Database ID: $query_data[0]br\n; echo Name: $query_data[1]brbr\n; echo Question:br $query_data[2]\n; echo hr\n; echo Post Reply = Yes input name=\post[$c]\ type=\radio\ value=\yes\\n; echo No input name=\post[$c]\ type=\radio\ value=\no\ checked\n; echo /tdtd width=\50%\ align=\\\n; echo Reply:brtextarea rows=\4\ cols=\50\ wrap=\hard\ name =\Reply[]\/textarea\n; echo /td/tr/table\n; echo brhrbr\n; $c = $c + 1; } echo input type=\submit\ value=\Submit\\n; echo /form\n; // End Snip // I tried creating a new array at the bottom of the loop like so == $id[]=$query_data[0]; and using a hidden field, but that failed. My problem is basically, how does one one make an array 'persist'. I looked through the archive, and didnt find anything substantial. If you need more info please email me. Thanks for listening Gerard Samuel wrote: Thanks for telling me that I was talking jibberish :) OK it worked, but now I have to figure out why its only updating the first row. Ill be back if I cant figure it out. Thanks all Tyler Longren wrote: yeah...jibberish. Should be this: UPDATE mpn_asklee SET reply='$Reply[$i]', Post='$post[$i]' WHERE ID='$counts' On Mon, 13 Aug 2001 15:20:17 -0400 Gerard Samuel [EMAIL PROTECTED] wrote: I have a database with 5 columns and cols 1,2,3 5 are filled. I want to insert into 4 and change 5. Could I use an UPDATE command to do this.. Here is what I have == $query = UPDATE mpn_asklee (Reply, Post) VALUES ('$Reply[$i]', '$post[$i]') WHERE ID = '$counts'; $result = mysql_query($query); If Im talking jibberish, let me know.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] UPDATE syntax
I have a database with 5 columns and cols 1,2,3 5 are filled. I want to insert into 4 and change 5. Could I use an UPDATE command to do this.. Here is what I have == $query = UPDATE mpn_asklee (Reply, Post) VALUES ('$Reply[$i]', '$post[$i]') WHERE ID = '$counts'; $result = mysql_query($query); If Im talking jibberish, let me know.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] UPDATE syntax
yeah...jibberish. Should be this: UPDATE mpn_asklee SET reply='$Reply[$i]', Post='$post[$i]' WHERE ID='$counts' On Mon, 13 Aug 2001 15:20:17 -0400 Gerard Samuel [EMAIL PROTECTED] wrote: I have a database with 5 columns and cols 1,2,3 5 are filled. I want to insert into 4 and change 5. Could I use an UPDATE command to do this.. Here is what I have == $query = UPDATE mpn_asklee (Reply, Post) VALUES ('$Reply[$i]', '$post[$i]') WHERE ID = '$counts'; $result = mysql_query($query); If Im talking jibberish, let me know.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] UPDATE syntax
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 try this syntax: UPDATE table SET col=value, col2=value2 ... WHERE ID=$id; -Original Message- From: Gerard Samuel [mailto:[EMAIL PROTECTED]] Sent: Monday, August 13, 2001 3:20 PM To: PHP Subject: [PHP] UPDATE syntax I have a database with 5 columns and cols 1,2,3 5 are filled. I want to insert into 4 and change 5. Could I use an UPDATE command to do this.. Here is what I have == $query = UPDATE mpn_asklee (Reply, Post) VALUES ('$Reply[$i]', '$post[$i]') WHERE ID = '$counts'; $result = mysql_query($query); If Im talking jibberish, let me know.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -BEGIN PGP SIGNATURE- Version: PGPfreeware 7.0.3 for non-commercial use http://www.pgp.com iQA/AwUBO3gpWsaXTGgZdrSUEQIQhQCg2bPek8JQFQYtMsl0+ltUrYu1jVAAmwf4 FQP9++hgdLDuHup2v7aUij5n =B6jL -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] UPDATE syntax
Thanks for telling me that I was talking jibberish :) OK it worked, but now I have to figure out why its only updating the first row. Ill be back if I cant figure it out. Thanks all Tyler Longren wrote: yeah...jibberish. Should be this: UPDATE mpn_asklee SET reply='$Reply[$i]', Post='$post[$i]' WHERE ID='$counts' On Mon, 13 Aug 2001 15:20:17 -0400 Gerard Samuel [EMAIL PROTECTED] wrote: I have a database with 5 columns and cols 1,2,3 5 are filled. I want to insert into 4 and change 5. Could I use an UPDATE command to do this.. Here is what I have == $query = UPDATE mpn_asklee (Reply, Post) VALUES ('$Reply[$i]', '$post[$i]') WHERE ID = '$counts'; $result = mysql_query($query); If Im talking jibberish, let me know.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] UPDATE syntax
Gerard Samuel [EMAIL PROTECTED] wrote: OK it worked, but now I have to figure out why its only updating the first row. snip Tyler Longren wrote: yeah...jibberish. Should be this: UPDATE mpn_asklee SET reply='$Reply[$i]', Post='$post[$i]' WHERE ID='$counts' /snip If each row has a unique value for ID then it will only update a single row. When in doubt what is happening store the SQL statement in a var like $sql and then echo $sql to the screen to check it over, pasting into database commandline to test results if necessary. -- Steve Werby President, Befriend Internet Services LLC http://www.befriend.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]