|
|
|
|
![]() ![]() |
Dec 12 2005, 07:34 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 407 Joined: 13-December 04 Member No.: 2,696 |
I have a page where I list a number of records from my db. Under each record I have a checkbox and a text field. At the bottom of the list I have a submit button. I want to be able to check various boxes and edit the text field then click the button to update all of the records. I currenlty have the following and it updates the records ok (checkbox, I haven't messed with the text field yet) when I first check the boxes but it will not update the db when I uncheck the boxes.
My form: PHP Code: CODE <form name="form1" method="post" action=myscript.php?rid=$rid> <input name="sortorder" type="text" id="sortorder" maxlength="2" /> <input type="checkbox" name="active1[$rid]" id="active" value="CHECKED" $active /> if(isset($_POST['active1'][$rid])); $active1=serialize($_POST['active1']); <input type="Submit" name="btn1" value="Update" </form> My script: PHP Code: CODE <?
header("Location: mypage.php"); include("../my db info.php"); $chkd = "CHECKED"; $db = mysql_connect(localhost,$myid,$mypw); mysql_select_db($mydb,$db); $res = mysql_query("SELECT * FROM mytable WHERE NOT (active='$chkd')",$db); if ($row = $active1) {{ foreach ($active1 as $rid => $value1) { mysql_query("UPDATE articles SET active='$value1' WHERE rid='$rid'",$db); }}} else {echo "Grrrr!";} mysql_close(); |
|
|
|
Dec 17 2005, 05:07 PM
Post
#2
|
|
|
Premium Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 183 Joined: 27-June 05 From: Minnesota Member No.: 8,734 |
I remember doing these before because they are a pain to get them to update if I remember right. Unfortunatly I can't remember where I used them.... otherwise I would show you the code for them because I did get the check boxs to work right.
All I remember is doing if statements to check if they are active or not, and using 1's and 0' for clicked or not. This probably won't help that much, but I figured I might as well say what I remember. I hope you figure it out, I'll check my site later to see if I have it hidden somewhere xJedix |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
|
Lo-Fi Version | Time is now: 30th August 2008 - 02:25 AM |