PHP - Multiple Checkboxes Html W/php: Error With Foreach
Hey all..
I have been messing around with some code with a form that has checkboxes on them, and the option of selecting more than one checkbox to submit to the database. However, I keep getting the error," Warning: Invalid argument supplied for foreach() in (mydirectory)". I have followed many tutorials and I don't see anything I am doing differently that they are, so I'm sure this is a simple fix, of something I am overlooking, or I am just horrible at this (new person). Here is the snippet of the HTML code for the checkboxes. Code: [Select] <label> <input type="checkbox" name="project_list[]" value="chat"/> Chat Project (age 18+ requirement)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="forums"/> Forums Project (age 18+ requirement)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="content"/> Content/Editorial Project (postcasts, blogging, etc.)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="technology" /> Technology Project</label> <br /> <label> <input type="checkbox" name="project_list[]" value="marketing"/> Marketing, Promotions and Publicity</label> <br /> <label> <input type="checkbox" name="project_list[]" value="designartwork"/> Design and Artwork</label> Here is the PHP code that I am using to do this. Code: [Select] include 'db.php'; mysql_select_db('skylers_training'); if($_POST['submit']) { $project_lists = $_POST['project_list']; foreach($project_lists as $list); //This is the line the code is getting the error on. And the section of the INSERT MYSQL CODE for this part. Code: [Select] $reginsert = mysql_query("INSERT INTO ... // the rest of the code (that works fine) follows this. '$list' // This is the line that is supposed to send data from the checklists to the database. When I submit the form, in addition to the error, nothing is submitted to the database table for the list (everything else works fine). Any insight into this, would be appreciated. Thanks! Similar TutorialsAlright the issue that I am having is that I need to get multiple lines into a variable to output later in the code. my $pieces variable is not returning anything, much less missing parts of it, but even the text code is not returning.
foreach($packages as $pack) { $weight+=$pack->weight; $items_no++; $singleweight=$pack->weight; $length=$pack->length; $height=$pack->height; $width=$pack->width; $pieces .= '<piece actual_weight="'.$singleweight.'" length="'.$length.'" height="'.$height.'" width="'.$width.'">'; } if(!empty($post_code) && $weight>0 && $items_no>0) { $data='?shipment='.urlencode('<shipment weight_system="IMPERIAL" shipper_number="'.$this->shipper_number.'" destination_postal_code="'.$post_code.'" service_type="'.$service.'">'.$pieces.'</shipment>').'&token='.$this->token; // $woocommerce->add_message('Items No:'.$items_no.'- Postalcode:'.$post_code.'- '); $resp=file_get_contents($this->canpar_url.$data,false,$context);If I do this in another method that only requires a single line (getting the total weight and number of items) it works fine, but this does not return the proper shipping cost for low weight items. On a site where higher weight items is shipped the plugin works fine. However I need to modify it to work based on dimensions. The result I am looking for is something like this: https://www.canpar.com/XML/RatingXML.jsp?shipment= <shipment weight_system="IMPERIAL" shipper_number="42500047" destination_postal_code="M1M1M1" service_type="1"> <piece actual_wieght="7" length="24" height="24" width="24"/> <piece actual_wieght="5" length="10" height="12" width="14"/> </shipment> &token=WZHBRS4KQYNAusing an output system I can output weight, packs, length, width, height but it does not return anything for $pieces and obviously shipping costs because I am getting an invalid xml response. $woocommerce->add_message('Weight: '.$weight.' Packs: '.$items_no.' Shipping cost : '.$atts['total_charge'].' Pieces: '.$item_box.' Length: '.$length.' Width: '.$width.' Height: '.$height); Hey forum, I am a new php user and am having some issues (probably pretty basic to the likes of more experienced users), I am trying to make a script that has 4 checkboxes and a submit button, the values of the checkboxes should be passed through the array using a foreach loop, I got the basic template setup but when trying to pass the array I ran into a few problems. If anyone would take a peek at my code and point me in the right direction it would be much appreciated. Thanks forum. Code: [Select] <html> <title>Toppings</title> <body> <p>What do you want on your pizza?</p> <form action="ProcessToppings.php" method="post"> <?php //define varialbes $Output_form = false; $submit = $_POST['submit']; if(isset($submit)) { if(empty($toppings)) { echo '<b>You forgot to choose a topping(s).</b>'; echo '<br>'; echo '<br>'; $Output_form = true; } else { $toppings=array("0", "1", "2", "3"); foreach ($toppings ['toppings'] as $order) { echo 'Your pizza will have these topping: ' . $toppings . '<br/>'; $Output_form = false; } } } ?> <input type="checkbox" name="toppings[0]" value="pepperoni" />Pepperoni<br /> <input type="checkbox" name="toppings[1]" value="sausage" />Sausage<br /> <input type="checkbox" name="toppings[2]" value="mushrooms" />Mushrooms<br /> <input type="checkbox" name="toppings[3]" value="olives" />Olives <p> <input type="submit" value="Place Order" name="submit" /></p> </form> </body> </html> Hi, my PHP code currently outputs the results from a users search by querying a backend postgresql database. As result/row is retuned to the user i would like to be able to detect whether or not they have checked a checkbox at the end of each rown in which case multiple rows can then be deleted from the database upon the user clicking a 'delete multiple records' button. I have no problem in being able to display the checkboxes on the webpage but i am a little unsure as to how to refernce them and detect which ones the user has checked. Given my database stores hostnames/IP addresses would it be best to name each checkbox to reflect the hostname or name the value it returns when checked to reflect the hostname. Given the above and that I also store the results of a users search in a $_SESSION['hosts'][][] array how can I then tie the two together? Thanks for reading. Hey forum, I am a new php user and am having some issues (probably pretty basic to the likes of more experienced users), I am trying to make a script that has 4 checkboxes and a submit button, the values of the checkboxes should be passed through the array using a foreach loop, I got the basic template setup but when trying to pass the array I ran into a few problems. If anyone would take a peek at my code and point me in the right direction it would be much appreciated. Thanks forum. [attachment deleted by admin] Excuse my late night slop! But I read a thread earlier and I am working on a dynamic way to address checkboxes with some intuitive messages while processing, and I cannot get this to work right w/out errors.. Any ideas where I am going totally wrong with this? <form name="" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> One <input type="checkbox" name="checkbox[]" value="checkOneValue" /><br /> Two <input type="checkbox" name="checkbox[]" value="checkTwoValue" /><br /> Three <input type="checkbox" name="checkbox[]" value="checkThreeValue" /><br /> Four <input type="checkbox" name="checkbox[]" value="checkFourValue" /><br /> Five <input type="checkbox" name="checkbox[]" value="checkFiveValue" /><br /> <input type="submit" name="submit" value="Echo Checkbox Data!" /> </form> <?php if (isset($_POST['submit'])) { $checkbox = $_POST['checkbox']; foreach ($checkbox as $checkboxValue) if (empty($checkboxValue)) { echo "$checkboxValue is emtpy"; } else { echo "<br>$checkboxValue is checked"; } }; ?> When no checkboxes are selected, I am dealing with this S%#$! Otherwise it works as intended.. Notice: Undefined index: checkbox in C:\wamp\www\php_practice\0\checkbox_echoing_1.php on line 24 Warning: Invalid argument supplied for foreach() in C:\wamp\www\php_practice\0\checkbox_echoing_1.php on line 26 I've got a page that has a dynamic number of checkboxes. I'm trying to figure out how to process the form once submitted. I've got a foreach loop set up, but I need to know the id of the checkbox so that I can make the change to my database accordingly. At the moment, my form is built with the checkboxes given the name of "checkbox['$id']", where id is pulled from the database. In my parsing script, I've got this foreach loop that I found on the internet Code: [Select] foreach($_POST["checkbox"] as $checkbox){ } But I don't know what to put in that foreach loop to be able to grab the id that the checkbox was given when the form was initially built? I'm struggling to find any examples on the Internet :/.. Denno Ok so i want to grab an id from the checkbox then grab the option drop down associated with that check box and update a mysql row here is my code so far any help is awesome help taaaanks guys <?php mysql_connect("localhost", "root", "root") or die(mysql_error()); mysql_select_db("db1") or die(mysql_error()); $query = "SELECT * FROM tickets ORDER BY id DESC"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { print "<input name='delete[]' value='{$row['id']}' type='checkbox'>"; mysql_connect("localhost", "root", "root") or die(mysql_error()); mysql_select_db("db1") or die(mysql_error()); $query2 = "SELECT * FROM admin"; $result2 = mysql_query($query2) or die(mysql_error()); print "<form name='namestoupdate' method='post' action='update.php'>\n"; print '<select>'; while($row2 = mysql_fetch_array($result2)) { if ($row2['priv']==prov){print '<option value="'.$row2['user'].'" name="prov['.$i++.']">'.$row2['user'].'</option>';} } print '</select>'; print "<input type='submit' value='submit' />"; print "</form>"; } ?> Visual aid Hi All!! I am a little confused. I have a form where I want around 15 different checkboxes, all or some of these can be checked. When the form is sent I insert the fields into a database. I am wondering how I can have only the fields checked saved into the database, without having to have a row for each field. Thanks Chris i am currently developing a voting system for a school project using dreamweaver.. on my vote page, i use checkboxes to select/vote a number of candidates. i want to automatically add/count the total tally and update my database upon submission of votes. since im new to php, all my codes are generated by dreamweaver..and dreamweaver doesn't have a function for handling multiple row update on database. can anyone please help with editing this code to make it work for my system? thanks in advance Code: [Select] <?php require_once('Connections/organizazone_db.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE tbl_candidates SET votecount=%s WHERE user_id=%s", GetSQLValueString(isset($_POST['vote[]']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['user[]'], "text")); mysql_select_db($database_organizazone_db, $organizazone_db); $Result1 = mysql_query($updateSQL, $organizazone_db) or die(mysql_error()); } mysql_select_db($database_organizazone_db, $organizazone_db); $query_rs_candi = "SELECT * FROM tbl_candidates"; $rs_candi = mysql_query($query_rs_candi, $organizazone_db) or die(mysql_error()); $row_rs_candi = mysql_fetch_assoc($rs_candi); $totalRows_rs_candi = mysql_num_rows($rs_candi); $query_rs_candi = "SELECT * FROM tbl_candidates"; $rs_candi = mysql_query($query_rs_candi, $organizazone_db) or die(mysql_error()); $row_rs_candi = mysql_fetch_assoc($rs_candi); $totalRows_rs_candi = mysql_num_rows($rs_candi); ?> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <table border="1"> <tr> <td> </td> <td>user_id</td> <td>votecount</td> </tr> <?php do { ?> <tr> <td><input name="vote[]" type="checkbox" id="vote[]" value="1" /> <label for="vote[]"></label></td> <td><label for="user[]"></label> <input name="user[]" type="text" id="user[]" value="<?php echo $row_rs_candi['user_id']; ?>" /></td> <td><?php echo $row_rs_candi['votecount']; ?></td> </tr> <?php } while ($row_rs_candi = mysql_fetch_assoc($rs_candi)); ?> </table> <br /> <br /> <input type="submit" name="submit" id="submit" value="Submit" /> <input type="hidden" name="MM_update" value="form1" /> </form> <?php mysql_free_result($rs_candi); ?> I have encountered a brick wall trying to use checkboxes. I am attempting to create a small form where I can record if a customer's item has been sent. The way I intend it to work is that the name and ID of the customer (stored in the 'customer' table) are retrieved through a query and displayed in two columns. In the third column is a checkbox beside the name and ID of each customer which, when ticked, sends a value to a second table called 'sentorders' for that particular person. As I am just trying to understand the basics of this for now, a list of all customers will be shown for the time being. The default value of the checkbox needs to be 'No' and if the checkbox is ticked the value should become 'Yes'. When a checkbox is ticked, the customer name, ID and current date are sent to the 'sentorders' table. Only if the box is ticked will the details be stored in the table. The problem I having is how do I set up the checkbox to work as described above. I have had a look at other questions online, but don't understand how it works. Any help would be appreciated. My current code is as follows. <?php $query = mysqli_query ($connect, "SELECT name, id FROM customer"); // Create Table echo '<table align="left"> <tr> <td align="left"><b>Name</b></td> <td align="left"><b>ID</b></td> <td align="left"><b>Order Sent</b></td> </tr>'; // Show Name/ID while ($row = mysqli_fetch_array($query)) { echo '<tr><form action="order_sent.php" method="post"><td align="left"> <td align="left">' . $row['name'] . '</a></td> <td align="left">' . $row['id'] . '</td> <input type="checkbox" name="order[];" value=''></tr>'; } echo '</table><p align="left"><input type="submit" name="enter" value="Update"/><input type="hidden" name="enter" value="TRUE" /></form>'; } ?> Hi all, iv been trying to compile a script that will allow users to select multiple checkboxs that will filter results from db..but to no avail. I have my data stored in mysql and have the queries saved seperatley. i.e. price = 0-500, 500-1000.etc. What im trying to achieve is to allow users to select a checkbox that will execute that particular query and also more importantly allow them to select 'multiple' checkboxes that will filter the results accordingly. I have never attempted to code this before although I am aware that it might involve arrays. If someone could give me a nudge in the right direction that would be great :-) hello. can (or rather how can) i put multiple checkboxes in to 1 db column? so, can i do this in 1 table: id - tick box id 1 - 1,2,3 2 - 4,5,6 3 - 7,8,9 and then relate that table to another table tick box id - name 1 - name1 2 - name2 3 - name3 etc.. if so, what format would i use in the db? varchar, enum or set (1,2,3 or '1','2','3') and how would i echo them out with the names from the second table? thanks I was wondering if this is possible. I have a list of criteria each with their own checkboxes, and I want to query a database when one or more of the checkboxes is submitted. So if 3 are checked, I want to query the database to find those 3 items. If one only is checked, I want to query the dataabse for one item. any ideas greatly appreciated thank you. this is basically a criteria based search hello all, im wondering if it is possible to have multiple check boxes that get created based on the number of rows in a table (one representing each row) Code: [Select] <input type='checkbox' name='approve[$tid]' value='ON'> and then have a submit button at the bottom of the page that will find all of the checkboxes (it could be 1, or 100) and submit it to my form handling page. thanks Hey All, I tried seraching, but I'm not sure what exactly to search for. Here's what I need to do, and any push in the right direction would be great: I have a PHP form, with the Following: Text Box: Student ID Checkboxes for Activities What I need to do is somehow loop through and make a new row for each activity. Example, if I entered Student ID 105 and Activities are Basketball, Baseball, and Chess Team, I need three different rows in the database each listing the individual activity and the student ID. Any suggestions? I know how to do this if it was one entry (radio buttons) but want to be able to enter multiple rows at a time. Thanks! I know how to pull data from sql table and limit down the results, what i wanted to do is pull data from a sql table 'finished' and list data that has paid='0' this is then limited to show the amount of rows set by variable 'maxPay' here is my list what im pulling atm; <h2>Payment </h2> <?php if($userType[user_type]==28){ $queryPay = mysql_query("SELECT * FROM finished WHERE paid='0'&&method!='FALSE'&&method!='credit';") or die(mysql_error()); $queryAdmin = mysql_query("SELECT maxPay FROM `admin`;") or die(mysql_error()); $row = mysql_num_rows($queryPay); //echo $row."row<br />"; $rowsArray = mysql_fetch_assoc($queryAdmin); $rows = $rowsArray[maxPay]; //echo $rows."rows<br />"; if($rows>$row){ $r=$row; } else{ $r=$rows; } $s=0; while($s<$r){ if($_POST[complete]==TRUE){ mysql_query("UPDATE `finished` SET `paid`='$_POST[paid]' WHERE `auctionID`='$_POST[aid]';"); $_POST[complete] = FALSE; } $s++; } $t=0; while($t<$r){ $queryuser = mysql_query("SELECT * FROM finished WHERE paid='0'&&method!='FALSE'&&method!='credit';") or die(mysql_error()); $user = mysql_result($queryuser, $t, "username"); //echo $user; $item = mysql_result($queryuser, $t, "itemName"); //echo $item; $value = mysql_result($queryuser, $t, "marketPrice"); //echo $value; $method = mysql_result($queryuser, $t, "method"); //echo $method; $id = mysql_result($queryuser, $t, "auctionID"); //echo $id; //echo $method; if($method=='isk'){ ?> <FORM method="post" action="pay.php"> <input type="hidden" name=complete value="TRUE" /> <input type="hidden" name=paid value="YES" /> <input type="hidden" name=username value="<? echo $user; ?>" /> <input type="hidden" name=aid value="<? echo $id; ?>" /> <input type="submit" value="Paid" /><? echo $user." won a ".$item." he selected to receive ".$value."ISK."; echo "<br />"; ?></FORM><? } elseif($method=='ship'){ ?> <FORM method="post" action="pay.php"> <input type="hidden" name=complete value="TRUE" /> <input type="hidden" name=paid value="YES" /> <input type="hidden" name=username value="<? echo $user; ?>" /> <input type="hidden" name=aid value="<? echo $id; ?>" /> <input type="submit" value="Paid" /><? echo $user." won a ".$item." he selected to receive the ship."; echo "<br />"; ?></FORM><? } else{ } $t++; } } else{ echo "You are not an Admin."; } ?> and pay.php: <?php header('Location: /admin.php'); include "connect.php"; echo $_POST[aid]; if($_POST[complete]==TRUE){ $tempID = (($_POST[aid])+1); mysql_query("UPDATE `finished` SET `paid`='$_POST[paid]' WHERE `auctionID`='$tempID';") or die(mysql_error()); $_POST[complete] = FALSE; } ?> at the moment i am listing all my data, and processing it using pay.php, each dataset has a "paid" button, i want to change this to using a checkbox at end of each data row, and a submit button at the bottom. this way i can select which rows to update and tick the checkbox, then click submit and those rows will then be updated the value '0' in db to a value of 'YES'. hope i explained myself clearly enough for some help. im a relative php noob still in training. Hi guys, I am struggling with a form containing multiple checkboxes with corresponding textboxes. Eg.: there are 5 checkboxes (XS, S, M, L, XL) and 5 textboxes (with values 3,4,5,6,8) that correspond to the checkboxes. I give all the checkboxes the name 'size[]' and the textboxes the name 'price[]'. The aim is to have my script set a boolean to true and update the corresponding price if the checkbox is selected. Unfortunately it does not work this way: checkboxes are only put in the array when they are selected, meaning that if I select only checkbox S and L, the array length is 2 only, but array length price is always 5, so size[1] does not correspond to price[1] necessarily. There probably is a better way to achieve what I need. Could anyone point me in the right direction? edit: BTW the number of items is dynamic: sometimes there will also be XXL or some items will be missing and I also need to set the price for items where the checkbox is not checked. Hi, I want to build into my html table that populates my database table to have a column for checkboxes with a delete button that takes the user to another page to confirm the deletion by outputting a message: Are you sure you want to delete ____, followed by a for loop to see how many checked records to get its ID in order to get its appropriate name. So I have a submit button with name attribute of "delete0" and the values of the input type of checkbox is $row['ID'], for some reason, I get the notice: "Notice: Undefined index: modifyArray in C:\display.php" and modifyArray is the name I give to the checkbox attribute (please see this in my display.php below) Here is my display.php Code: [Select] <table border="border"> <!--NB: checkbox form for multiple delete/update/insert--> <form method="post" action=""> <input type='submit' value='DELETE' name='delete0' /> <?php session_start(); require 'bellSessionDisconnect.inc'; require 'bellConnect.inc.php'; $result=mysql_query("SELECT ID, Image, Name, Manufacturer, Price, Description, SimSupport FROM bellProducts"); //phpinfo(); //NB: print table headings if(mysql_num_rows($result))//if there is at least one entry in bellProducts, make a table { //$counter+=1; print "<table border='border'>"; print "<tr> <th>ID</th> <th>Select entries to modifiy</th> <th>Image</th> <th>Name</th> <th>Manufacturer</th> <th>Price</th> <th>Description</th> <th>SimSupport</th> <th colspan='2' align='center'>Modify</th> </tr>"; //NB: now output each row of records while($row=mysql_fetch_assoc($result)) { //extract($row); "<tr align='center'> <td>$row[ID]</td> <td><input type='checkbox' name='modifyArray[]' value='$row[ID]' /></td> <td>"; if(!empty($row['Image'])) { $curImage=$row['Image']; } else if(empty($row['Image'])) { $curImage='fileUploadIcon.jpg'; //$title="please upload item image"; } print "<img src=$curImage width='70px' height='90px' /> </td> <td> $row[Name] </td> <td> $row[Manufacturer] </td> <td> $$row[Price]</td> <td align='left'>$row[Description]</td> <td>$row[SimSupport]</td> <td><a href='bellUploadForm.php?ID=$row[ID]'>UPLOAD IMAGE</a></td> <td><a href='bellUpdateForm.php?ID=$row[ID]'>UPDATE</a></td> </tr>"; //}//END INNER IF }//END WHILE }//END BIG IF ?> <?php if(array_key_exists('delete0', $_POST)) { $modifyArray=$_POST["modifyArray"]; if(!empty($modifyArray)) { header("Location: http://localhost/bellDeleteForm.php"); exit(); } } ?> </form> </table> I will worry about redirecting to bellDeleteForm.php to confirm the records the user wants to delete after I get this going, please help!!! thanks Can someone please help? I am simply trying to email process a form with checkboxes and then redirect to a thank you page. It works fine as long as at least one checkbox is checked. It breaks if no checkboxes are checked using the implode function to list the "interests". I'm getting this error (and no redirect to my thank you page): Warning: implode() [function.implode]: Invalid arguments passed... <?php if (isset($_REQUEST['submit'])) { $email = $_REQUEST['email']; $firstName = $_REQUEST['firstName']; $lastName = $_REQUEST['lastName']; $address = $_REQUEST['address']; $city = $_REQUEST['city']; $state = $_REQUEST['state']; $zipcode = $_REQUEST['zipcode']; $homePhone = $_REQUEST['homePhone']; $cellPhone = $_REQUEST['cellPhone']; $interest = $_REQUEST['interest']; $imploded_interest = implode(',',$interest); $comments = $_REQUEST['comments']; $to = 'myemailhere@yahoo.com'; $subject = 'Volunteer Signup'; $message = " <html> <head> <title>Volunteer Signup</title> </head> <body> <p>Hello,<br/>A visitor has submitted the following information from the volunteer page:</p> <p><b>$firstName $lastName</b><br/> $address<br/> $city, $state $zipcode<br/><br/> Home Phone: $homePhone<br/> Cell Phone: $cellPhone<br/> Email: <strong>$email</strong><br/><br/> I would like to help in the following ways:<br/> $imploded_interest </p><br/> <p>$firstName would also like share the following comments:<br/> <q><i>$comments</i></q> </p> </body> </html> "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Volunteer Signup <myemailhere@yahoo.com>' . "\r\n"; mail($to, $subject, $message, $headers); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Volunteer</title> </head> <body> <form id="VolunteerForm" method="post" action="thankyou.php"> <table> <tr> <td style="width:150px;">Email Address:</td> <td><input name="email" type="text" id="email" /></td> <td style="width:320px;" class="padtr"><strong>Ways I can help:</strong></td> </tr> <tr> <td>First Name:</td> <td><input name="firstName" type="text" id="firstName" /></td> <td class="padtr"><input name="interest[]" value="yard-sign" type="checkbox"/> Put a yard sign in my yard</td> </tr> <tr> <td>Last Name:</td> <td><input name="lastName" type="text" id="lastName" /></td> <td class="padtr"><input name="interest[]" value="fundraiser-at-home" type="checkbox" /> Host a fundraiser at my home</td> </tr> <tr> <td>Address:</td> <td><input name="address" type="text" id="address" /></td> <td class="padtr"><input name="interest[]" value="phone-calls" type="checkbox" /> Make phone calls to friends and family</td> </tr> <tr> <td>City:</td> <td><input name="city" type="text" id="city" /></td> <td class="padtr"><input name="interest[]" value="mailings" type="checkbox" /> Help with mailings</td> </tr> <tr> <td>State:</td> <td><input name="state" type="text" id="state" /></td> <td class="padtr"><input name="interest[]" value="doors-literature" type="checkbox" /> Help knock on doors and distribute literature</td> </tr> <tr> <td>Zip Code:</td> <td><input name="zipcode" type="text" id="zipcode" /></td> <td class="padtr"><input name="interest[]" value="donate" type="checkbox" /> Make a donation</td> </tr> <tr> <td>Home Phone:</td> <td><input name="homePhone" type="text" id="homephone" /></td> <td class="padtr"><input name="interest[]" value="endorsement" type="checkbox" /> Use my name as an endorsement</td> </tr> <tr> <td>Cell Phone:</td> <td><input name="cellPhone" type="text" id="cellphone" /></td> <td class="padtr"><input name="interest[]" value="newsletter" type="checkbox" /> Sign up for our newsletter</td> </tr> <tr> <td>Comments:</td> <td><textarea name="comments" id="comments" rows="5" cols="17"></textarea></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> <input type="submit" name="submit" id="submit" value="Submit Now" /> <input type="reset" name="reset" id="reset" value="Clear Form" /></td> </tr> </table> </form> </body> </html> Hello all, i have a table that displays data from mysql, now i want to update multiple rows from that table with checkboxes, the value will basically just switch from 'new' to 'done' so far i have this: Code: [Select] <tbody> <tr class="first"> </tr> <?php $ticketde=0; while ($ticketde < $numpscde) { $f1pscde=mysql_result($ticketresultde,$ticketde,"id"); $f2pscde=mysql_result($ticketresultde,$ticketde,"ticket"); $f4pscde=mysql_result($ticketresultde,$ticketde,"date"); $f5pscde=mysql_result($ticketresultde,$ticketde,"ip"); $f6pscde=mysql_result($ticketresultde,$ticketde,"done"); $setdone = ($f6pscde["done"] == 'n') ? "<a href=\"donepsc.php?id=".$f1pscde."\"><img src=\"ico_new.gif\" alt=\"new\" /></a>" : $f6pscde["done"]; if(isset($_POST['setdone'])){$checkbox = $_POST['checkbox']; $id = "('" . implode( "','", $checkbox ) . "');" ; $sql = "UPDATE ticket SET done='done' WHERE id='$f1pscde'"; $result = mysql_query($sql) or die(mysql_error()); } ?> <tr class="first"> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f1pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f2pscde; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $f5pscde; ?></font></td> <td class="tc"><font face="Arial, Helvetica, sans-serif"><?php echo $setdone; ?></font></td> <td class="tc"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $f1pscde['id']; ?>"></td> </tr> <?php $ticketde++; } ?> </tbody> </table> <center><input type="submit" name="setdone" id="setdone" value="Set selected to done" class="button"/> - <input type="submit" name="exporttxt" id="exporttxt" value="Export selected to .txt" class="button"/> </center> </fieldset> </form> I found that checkbox code sample on some other site and tried to implement it, i don't really know where to go from here, as it's a total mess to me now, any help would be greatly appreciated. |