PHP - Checkboxes Via Post Don't Create Array
Hello to everyone,
I have a strange problem and I'm not able to solve it by myself and I need your help!
I have three simple checkboxes that process via POST their value. But with PHP I cannot have an array with the three indexes (if everyone checked) but only an array with the first checkbox checked. The code is very simple:
<?php $scelta = isset($_POST['user_rights']) ? $_POST['user_rights'] : array(); if (isset($_POST["user_rights"])){ print_r($scelta);}else{ ?> <form method="post"><input type="checkbox" name="user_rights[]" value="0"> 0<br><input type="checkbox" name="user_rights[]" value="1"> 1<br><input type="checkbox" name="user_rights[]" value="2"> 2 <input type="submit"></form> <?php} ?>The output if I check all the checkboxes is: Array ( [0] => 0 ) If I try this code on another server it works (it returns the complete array), but if i run it on my web server, it doesn't (it returns only the first item). Do you have any experience with this error? Do you know if there is some configuration to change? Thanks in advance. Rob Similar Tutorialshey i am using a MySql database and i need to create a dynamic HTML table with one of its columns as checkboxes.so i have to create multiple checkboxes.but these checkbox values are to be stored in a mysql table and then later retrieved when form reloads.and depending on previous state when form was submitted, the newly created checkboxes have to be checked in the same manner.so how do i store multiple checkbox values in my table and also how do i retrieve them? please help. $post='{"cart_items":[{"configuration":{"price":100,"recharge_number":"9999999999"},"product_id":"999","qty":1}]}';i try this n reslut was :There are no valid items in cart: help me plz Edited by ShivaGupta, 30 November 2014 - 01:11 AM. Have a look at this image Here is the part of the form code that makes them into arrays $sql="select * from products"; $res=mysql_query($sql); WHILE($fetch=mysql_fetch_assoc($res)){ echo "<td><input type=hidden name='desBox[]' id='desBox[]' value='".$fetch['prod_id']."'>".$fetch['prod_name']."</td> <td><input type=text id=quantBox[] maxlength=6 name=quantBox[]></td> <td><input type=text maxlength=6 id=teethBox[] name=teethBox[]></td>"; echo "</tr>";} Hi
I'm totally green when it comes to php, but am learning it the hard way. Any help is appreciated.
I have a form the currenty uses a custom taxonomy but it has a text field, and I want it to call and list the taxonomy items with checkboxes so instead of entering words the visitor can just multiple check off the taxonomies that relate to them.
It's a job board, this is the job skill part that relates to their expertise.
There is a job category in the form, and I tried to use the syntax to get the taxonomy and implode it but
I really don't know what I'm doing.
See the "skills" item? I want to make that a bunch of checkboxes to allow selection the the pre defined resume_skills taxonomy.
http://outsourcing.j...it-resume-free/
Any help would be great, and I'm not sure what code I need to put in here.
Mark
Rules: 1) It has to be legit and actually work and have a useful function in society/web world. 2) The code cannot be minimized into one line. It has to have line breaks. (Not necessarily for each new function or short hand property, but so it's partly readable) 3) It has to be written in PHP or Javascript. For example, (Not my original code) but I'll start: A time_ago function: function timeago($tm,$rcs = 0) { $cur_tm = time(); $dif = $cur_tm-$tm; $pds = array('second','minute','hour','day','week','month','year','decade'); $lngh = array(1,60,3600,86400,604800,2630880,31570560,315705600); for($v = sizeof($lngh)-1; ($v >= 0)&&(($no = $dif/$lngh[$v])<=1); $v--); if($v < 0) $v = 0; $_tm = $cur_tm-($dif%$lngh[$v]); $no = floor($no); if($no <> 1) $pds[$v] .='s'; $x = sprintf("%d %s ",$no,$pds[$v]); if(($rcs == 1)&&($v >= 1)&&(($cur_tm-$_tm) > 0)) $x .= time_ago($_tm); return $x; }Your turn! Edited by Monkuar, 24 January 2015 - 05:06 PM. NOTE - Please read the information first as it contains important information to understand the problem. Rules → • There are 9 Columns(C1,C2,C3,C4,C5,C6,C7,C8,C9) [ Max columns will be 9] • The number of Rows can vary from 3,6,9,12,15,18 (Max). In this case Number of Rows shall be 12 Number of Rows = No of Tickets (Max Allowed 6) x Rows Per Ticket (Max Allowed 3). Thus, Max Rows can be 18 • Each Row is required to have 4 Blank Spaces and 5 Filled with Numbers • All numbers available in the Column Array have to be utilized • This configuration of an shall create a matrix of 9 Columns & 12 Rows (3 x 4 Tickets), which is 108 MATRIX BLOCKS where only a maximum of 60 numbers can be filled out of 108 available blocksrandomly with the above conditions being met 100%. • The numbers in column must be arranged / sorted in ASCENDING ORDER (For coding logic purpose, as soon as the number is assigned to the new MATRIX MAP use array_shift() or unset() the number so as to avoid repetition Example - Row 1 and Column 1 shall generate a MATRIX BLOCK - R1C1 Row 3 and Column 7 shall generate a MATRIX BLOCK - R3C7 Matrix Block can also be termed as Matrix Cell for your ease (if needed) MASTER SET OF ARRAY WITH NUMBERS array( "C1"=> array( 1, 2, 3, 5, 6, 7, 9 ), //7 Numbers "C2"=> array( 13, 14, 15, 17, 18, 19 ), //6 Numbers "C3"=> array( 21, 22, 23, 24, 25, 26, 30 ), //7 Numbers "C4"=> array( 31, 33, 34, 36, 37, 38, 39 ), //7 Numbers "C5"=> array( 41, 42, 46, 47, 48, 49, 50 ), //7 Numbers "C6"=> array( 51, 52, 53, 54, 55, 57, 58 ), //7 Numbers "C7"=> array( 61, 62, 64, 65, 69, 70 ), //6 Numbers "C8"=> array( 71, 74, 75, 76, 77, 78 ), //6 Numbers "C9"=> array( 82, 83, 85, 87, 88, 89, 90 ) //7 Numbers ); The above array has 60 Numbers to be filled out of 108 MATRIX BLOCK / CELL which meets the condition that for a FULL BLOCK containing 4 MINI BLOCKS WITH 3 ROWS (max. allowed) EACH I have been able to generate this without any issue meeting all the conditions of the Columns My Allocation Matrix Array will look like array( "R1"=> array( "C1"=> true, // Means that MATRIX BLOCK R1C1 will be NOT EMPTY "C2"=> false, // Means that MATRIX BLOCK R1C2 will be EMPTY "C3"=> true, "C4"=> false, "C5"=> true, "C6"=> false, "C7"=> true, "C8"=> true, "C9"=> false ), "R2"=> array( "C1"=> false, "C2"=> true, "C3"=> false, "C4"=> true, "C5"=> false, "C6"=> true, "C7"=> true, "C8"=> true, "C9"=> false ), "R3"=> array( "C1"=> true, "C2"=> true, "C3"=> true, "C4"=> true, "C5"=> false, "C6"=> false, "C7"=> false, "C8"=> false, "C9"=> true ), "R4"=> array( "C1"=> true, "C2"=> true, "C3"=> true, "C4"=> false, "C5"=> true, "C6"=> true, "C7"=> false, "C8"=> false, "C9"=> false ), "R5"=> array( "C1"=> false, "C2"=> false, "C3"=> false, "C4"=> false, "C5"=> true, "C6"=> true, "C7"=> true, "C8"=> true, "C9"=> true ), "R6"=> array( "C1"=> true, "C2"=> true, "C3"=> false, "C4"=> true, "C5"=> false, "C6"=> true, "C7"=> false, "C8"=> false, "C9"=> true ), "R7"=> array( "C1"=> false, "C2"=> false, "C3"=> true, "C4"=> false, "C5"=> true, "C6"=> false, "C7"=> true, "C8"=> true, "C9"=> true ), "R8"=> array( "C1"=> true, "C2"=> false, "C3"=> false, "C4"=> true, "C5"=> false, "C6"=> false, "C7"=> true, "C8"=> true, "C9"=> true ), "R9"=> array( "C1"=> true, "C2"=> false, "C3"=> true, "C4"=> false, "C5"=> true, "C6"=> true, "C7"=> false, "C8"=> false, "C9"=> true ), "R10"=> array( "C1"=> false, "C2"=> true, "C3"=> true, "C4"=> true, "C5"=> true, "C6"=> false, "C7"=> true, "C8"=> false, "C9"=> false ), "R11"=> array( "C1"=> false, "C2"=> true, "C3"=> false, "C4"=> true, "C5"=> true, "C6"=> true, "C7"=> false, "C8"=> true, "C9"=> false ), "R12"=> array( "C1"=> true, "C2"=> false, "C3"=> true, "C4"=> true, "C5"=> false, "C6"=> true, "C7"=> false, "C8"=> false, "C9"=> true ) ); In the above array R stands for Row, C for Column, TRUE/FALSE (Boolean) means that if TRUE a Number can be filled in the resulting MATRIX BLOCK / CELL ( Row[Number]Column[Number] ) else if FALSE the MATRIX BLOCK / CELL shall be EMPTY The result for the above shall be
PROBLEM : I am unable to understand what should possibly be the logic & loop used here for creating a MATRIX ALLOCATION MAP as shown above I have tried while, foreach & for but unable determine the perfect combination which would meet the conditions. (Tried all of the above with Nested Loops also) Edited May 1, 2020 by AlphaMikeTags how to cross reference $_POST array 'checkboxes[]' with mysql field I have a form that is submitted so the user can select which results to print. but I am having problems getting the results to show correctly. how do I correctly cross reference the form data with the mysql Code: [Select] $getRequests = mysql_query("SELECT * FROM requests WHERE `customer_email`='{$_SESSION['FM_user']}'"); while($request = mysql_fetch_assoc($getRequests)) { if (!in_array($request['request_id'],array($_POST[request]))) { echo '<li style="font-size:10px; border-bottom: 0.1em solid #D0D0D0"> <div class="leftfloat"> <input type="checkbox" name="request[]" value="',$request['request_id'],'"> </div> <div class="leftfloat"> <em>',$request['request_id'],'</em> </div><div class="leftfloat"> | </div> <div class="leftfloat"> <em>',$request['customer_name'],'</em> </div><div class="leftfloat"> | </div> <br style="clear:both"> </li>'; } } Hi, i have tried everything i can think of to get this to work correctly. What is below here, is what i have last tried to work with..: basically the script allows the use to register an email account on a cpanel domain. Everything works perfectly but then i added a option for banned words now i cant get the script to work.. basically what happens is: the user creates an email account, if the account is not a banned word and does not exist, then the message echoes success, and the $_Post values are also entered into the database under the users name. and the email is also created with the $f fopen if success the email form also does not show.. so only one email per user.. i just cant get it to work with the banned words included.. what to note:: this is a function in a function.. $bannedemailwords='customerinformation,custinfo,customerinfo,custtext,custsupport,customersupport,admin,accounts'; $bannedmail=explode(',', $bannedemailwords); $bannedmail = array_unique($bannedmail); sort($bannedmail); foreach($bannedmail as $noemail) //the selected username if ($Config['enablemyemailapp_enable'] == '0' && $_POST['cfg_enablemyemailappaddress_enable'] !== $noemaill && $_POST['cfg_enablemyemailappaddressdomain_enable'] !== 'Select a domain'){ $cpuser = 'ausername'; $cppass = 'apassword'; $cpdomain = 'adomain'; $cpskin = 'askin'; $epass = 'somepassword'; $equota = 'somequota'; $euser = $_POST['cfg_enablemyemailappaddress_enable']; $epass = $_POST['emailspassword_enable']; $edomain = $_POST['cfg_enablemyemailappaddressdomain_enable']; if (!empty($euser) && $euser !=='nomail') while(true) { $f = fopen ("http://$cpuser:$cppass@$cpdomain:2082/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass"a=$equota", "r"); if (!$f) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail = 'The email '.$euser.'@'.$edomain.' is a restricted email account.'; break; } $enablemyemailapp_enable = '1'; $enablemyemailappaddress_enable = $_POST['cfg_enablemyemailappaddress_enable']; $enablemyemailappaddressdomain_enable = $_POST['cfg_enablemyemailappaddressdomain_enable']; $msgemail ='<center><font color="#ff0033">Your Email '.$euser.'@'.$edomain.' has been created.</font></center>'; while (!feof ($f)) { $line = fgets ($f, 1024); if (ereg ("already exists", $line, $out)) { $enablemyemailapp_enable = '0'; $enablemyemailappaddress_enable = 'Replace with a Name'; $enablemyemailappaddressdomain_enable = 'Select a domain'; $msgemail ='<center><font color="#ff0033">The email account '.$euser.'@'.$edomain.' already exists.</font></center><br><center>Please try again!</center>'; break; } } echo $msgemail; $_POST['cfg_enablemyemailapp_enable']= $enablemyemailapp_enable; $_POST['cfg_enablemyemailappaddress_enable']=$enablemyemailappaddress_enable; $_POST['cfg_enablemyemailappaddressdomain_enable']=$enablemyemailappaddressdomain_enable; @fclose($f); break; } } Hi, I am working on a betting API, The data comes from an XML Feed. I am using a PHPPhar file to iterate the XML data, Seems to work really well. What I need to do now is iterate each "outcome" type and order it by the highest decimal to lowest decimal value (Best odds) My current array of data from the XML looks like this (See pastebin for full version) : SimpleXMLElement Object ( [Outcome] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 1 [name] => 1X2 ) [Bookmaker] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 8 [name] => Bet365 [isLive] => false [lastUpdate] => 2015-01-15T04:17:03 [bookieEventID] => [bookieLeagueID] => [BookieOfferTypeID] => 40 ) [Odds] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 10026743121640944 [bet] => 1 [startPrice] => 9/2 [currentPrice] => 5/1 [line] => [LastUpdate] => 2015-01-15T04:17:03 [bookieOutcomeID] => [Status] => Open ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 10026743131640944 [bet] => 2 [startPrice] => 31/50 [currentPrice] => 57/100 [line] => [LastUpdate] => 2015-01-15T04:17:03 [bookieOutcomeID] => [Status] => Open ) ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 10026743511640944 [bet] => X [startPrice] => 11/4 [currentPrice] => 3/1 [line] => [LastUpdate] => 2015-01-14T17:55:48 [bookieOutcomeID] => [Status] => Open ) ) ) )[1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 2 [name] => Under/Over ) [Bookmaker] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 8 [name] => Bet365 [isLive] => false [lastUpdate] => 2015-01-15T15:25:31 [bookieEventID] => [bookieLeagueID] => [BookieOfferTypeID] => 981 ) [Odds] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 14185280871640944 [bet] => Over [startPrice] => 1/20 [currentPrice] => 3/50 [line] => 0.5 [LastUpdate] => 2015-01-15T15:15:14 [bookieOutcomeID] => [Status] => Open ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 8219239561640944 [bet] => Over [startPrice] => 9/50 [currentPrice] => 1/5 [line] => 1.25 [LastUpdate] => 2015-01-15T08:30:43 [bookieOutcomeID] => [Status] => Open ) ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 13305582441640944 [bet] => Over [startPrice] => 29/100 [currentPrice] => 8/25 [line] => 1.5 [LastUpdate] => 2015-01-15T15:25:31 [bookieOutcomeID] => [Status] => Open ) ) [3] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 15814388431640944 [bet] => Over [startPrice] => 7/20 [currentPrice] => 2/5 [line] => 1.75 [LastUpdate] => 2015-01-15T08:30:43 [bookieOutcomeID] => [Status] => Open ) ) [4] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 9542253841640944 [bet] => Over [startPrice] => 9/20 [currentPrice] => 13/25 [line] => 2.0 [LastUpdate] => 2015-01-15T08:53:07 [bookieOutcomeID] => [Status] => Open ) ) [5] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 18435608691640944 [bet] => Over [startPrice] => 17/25 [currentPrice] => 77/100 [line] => 2.25 [LastUpdate] => 2015-01-15T08:53:07 [bookieOutcomeID] => [Status] => Open ) )[2] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 17 [name] => Both Teams To Score ) [Bookmaker] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 8 [name] => Bet365 [isLive] => false [lastUpdate] => 2015-01-14T17:55:48 [bookieEventID] => [bookieLeagueID] => [BookieOfferTypeID] => 10150 ) [Odds] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 14294083431640944 [bet] => No [startPrice] => 83/100 [currentPrice] => 73/100 [line] => [LastUpdate] => 2015-01-14T17:55:48 [bookieOutcomeID] => [Status] => Open ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 18070790851640944 [bet] => Yes [startPrice] => 83/100 [currentPrice] => 1/1 [line] => [LastUpdate] => 2015-01-14T17:55:48 [bookieOutcomeID] => [Status] => Open ) ) ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 31 [name] => William Hill [isLive] => false [lastUpdate] => 2015-01-15T15:58:30 [bookieEventID] => [bookieLeagueID] => [BookieOfferTypeID] => 226344747 ) [Odds] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 11341591031640944 [bet] => No [startPrice] => 73/100 [currentPrice] => 67/100 [line] => [LastUpdate] => 2015-01-15T15:58:30 [bookieOutcomeID] => [Status] => Open ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [id] => 10996680931640944 [bet] => Yes [startPrice] => 1/1 [currentPrice] => 11/10 [line] => [LastUpdate] => 2015-01-15T15:58:30 [bookieOutcomeID] => [Status] => Open ) ) ) )Is it possible build an array of outcomes, Then sort by the best decimal price. (I have a function built that can convert the "currentPrice" to decimal. Thnak You! Hello can anyone help me out with code to create a 2 dimension array from 2 single dimension array. for example $path = array('base', 'category', 'subcategory', 'item'); $location=array('india','USA','UK','RUSSIA',); now i need to have a @D array which have the following structure $final[0]=array('base','india'); $final[1]=array('category','USA'); $final[2]=array('subcategory','UK'); $final[3]=array('item','RUSSIA'); I seem to be having a problem with this code. It's supposed to parse the file info.txt and explode comma separated values into an array and then add each value from that file to the end of a URL and POST that url. What I'm getting now is just the first number in the array. Anyway, here's the code: Code: [Select] <?php $FileName = "info.txt"; $FileHandle = fopen($FileName,"r"); $FileContent = fread ($FileHandle,filesize ($FileName)); fclose($FileHandle); // You can replace the \t with whichever delimiting character you are using $SplitContent = explode("\t", $FileContent); foreach($SplitContent as $CurrValue) { header('Location: http://website.com/file.php?value=' . $CurrValue); } ?> I have a dynamic form that I am writing a script for to allow people to modify the fields of the form. I am taking all of the information that they have entered into the post array. Where I am having a problem is that it is not showing all of the fields in the post array. One of the fields is an image field and the name of the image does not show up in the array when I do print_r or anything. One other thing that I would like to know is how to get rid of the submit key and value from the array. I have tried using the unset method but it still shows up in the array. Code: [Select] <?php session_start(); include ('includes/connection.php'); connect(); $table = $_GET['table']; $id = $_GET['id']; $errors = array(); $mod_sql = "SELECT * FROM $table WHERE id = '$id'"; $mod_sql_result = mysql_query($mod_sql); $info = mysql_fetch_assoc($mod_sql_result); $mod_form = "<form name='insert_table' id='insert_table' action='" . $_SERVER['PHP_SELF'] . "?id=$id&table=$table' method='post' enctype='multipart/form-data'> <fieldset> <legend>table information</legend> <input TYPE='hidden' VALUE='" . $table . "' />"; foreach ($info as $key => $val) { $header = str_replace("_", " ", $key); if ($key == 'id') { $mod_form .= "<p>" . $header . ": <input name='" . $key . "' id='" . $key . "' type='text' value='" . $val . "' readonly='readonly' /></p>"; } else if ($key == 'image') { $mod_form .= "<p>Current image: <img style='vertical-align: text-top;' src='../db_images/ad_images/" . $val . "' /><input type='checkbox' name='delete_image' id='delete_image' value='" . $val . "' />Delete this image?</p> <p>" . $header . ": <input name='" . $key . "' id='" . $key . "' type='file' /></p>"; } else { $mod_form .= "<p>" . $header . ": <input name='" . $key . "' id='" . $key . "' type='text' value='" . $val . "' /></p>"; } } $mod_form .= " <p> <input type='submit' name='submit_mod' id='submit_mod' /> </p> </fieldset> </form> "; echo $mod_form; if (isset($_POST['submit_mod'])) { $table = $_POST['table']; $allowed_ext = array('jpg', 'jpeg', 'png', 'gif'); $file_name = $_FILES['image']['name']; $file_ext = (explode(".", $file_name)); $file_ext = strtolower(end($file_ext)); $file_size = $_FILES['image']['size']; $file_tmp = $_FILES['image']['tmp_name']; if (isset($_POST['delete_image'])) { $delete_image_name = $_POST['delete_image']; unlink('../db_images/ad_images/' . $delete_image_name); } if ($file_name != " ") { $new_image = $file_name; move_uploaded_file($file_tmp, '../db_images/ad_images/' . $file_name); } // This is the section of code that I am having trouble with foreach ($_POST as $key => $value) { if ($key == 'image') { $value = $new_image; } $insert_query = "UPDATE $table SET `$key` = '$value' WHERE id = $id"; $insert_action = mysql_query($insert_query); } echo $insert_query; } if (mysql_error()) { $error = "<strong>MySQL error</strong>:<br />" . mysql_errno() . ": " . mysql_error() . "\n<br>When executing:<br>\n$insert_query\n<br>"; $page = $_SERVER["REQUEST_URI"]; $log = "INSERT INTO db_error (`error_id`, `error_page`,`error_text`,`query`) VALUES ('','$page','" . mysql_real_escape_string($error) . "','" . mysql_real_escape_string($mod_sql) . "')"; $insert_log = mysql_query($log); echo $error; if ($insert_log) { echo "<p>Error has been added to the error log</p><p>The error id number is " . mysql_insert_id() . ""; } else { echo "Error adding to error log<br />" . mysql_errno() . ": " . mysql_error(); } } ?> Hi all, Can anyone tell me why the declaration below won't work??? Thnx Ryflex $amount = array(0 => $_POST['$n[0]'], 1 => $_POST['$n[1]'], 2 => $_POST['$n[2]'], 3 => $_POST['$n[3]']); Hi, Here is simple question. I have this array: array([0]=>name [1]=>Tony); How can i change into array(name=>Tony); ? Thank you, ayok Hi - I am uploading Post variables off a form relating to products and customer orders. If a product has a quantity attached to it then all the POST variables relating to that product need to INSERTED into the DB. If a product has just an empty string in it's quantity variable, then that product does not get INSERTED. So I thought of 2 different approaches: A) I could filter the Quantity Post variable for a positive values then create a new array only containing products with positive quantities. B) I could loop through the product Id (ProdID) POST and using a condition pull out the products with a positive quantity for Insertion. I have been experimenting with B and have failed miserably. However I have succeeded excellently in building some code which INSERTS all the products regardless of their quantities ( see below ) - not ideal as it enters products with empty quantities. I would prefer to adapt what I have rather than throw it away. Can someone kind person give this student a hand with some advice in adapting what I have got ? MANY MANY THANKS ! Code: [Select] <?php function insert_tel_order(){ $lastname = $_POST['lastname']; $orderid = strtoupper(substr($lastname,0,3)).(substr(time(),-4)); //Creates a unique order number $customerid = $_POST['customerid']; $pickupdate = $_POST['pickupdate']; $deliverylocationid = $_POST['deliverylocationid']; $orderdate = $_POST['orderdate']; foreach ($_POST['prodid'] as $arrkey => $prodid){ $quantity = $_POST['quantity'][$arrkey]; $prodid = $_POST['prodid'][$arrkey]; $price = $_POST['price'][$arrkey]; $ordervalue = $quantity * $price; $sql =" INSERT INTO `order` (id, orderid,orderdate,customerid, deliverylocationid,pickupdate,prodid,price, quantity, ordervalue, status) VALUES ('', '$orderid',$orderdate,$customerid,$deliverylocationid,$pickupdate,$prodid,$price,$quantity,$ordervalue,'')"; $this->db->query($sql); } } ?> i have a shopping cart set up with mysql with a $_COOKIE['cart_id'] used to call all rows with cart_id... i have a while loop print out all the items in the cart $sql2 = mysql_query("SELECT * FROM cart WHERE cart_id = '$cart_id'") or die(mysql_error()); while($row = mysql_fetch_array($sql2)){ then i have it echo out the name...desc... quantity of each item... but the quantity is set up to be able to change and i have a form set up and i'd like to have each item be able to be changed at once if they wanted....but being multiple rows... there could be multiple $_POST['quantity']... echo "<td><input type='text' name='quantity' value='".$quantity."'/></td>"; there is a unique id for each row in the table that i'd like to set up with an array to post... i'd like to set up an array $array[$uniq_id] => $quantity; and somehow POST this array name='$array[]' and then on the action end... be able to call it by having foreach($quantity as $uniq_id => $qty){ mysql_query("UPDATE cart SET quantity='$qty' WHERE id='$uniq_id' "); } i'm not sure if i'm approaching this the right way... the array part is leaving me stuck...any help is appreciated..thank you! $space = array('3x3', '3x3_6x6', '3x3_6x6', '6x6_10x10', '10x10_20x20', '20x20_40x40', 'above_40x40'); Hi all This is probably the easiest question ever , but I am not familiar with arrays , so hope somebody can help me User post this checkbox form (array): <input type="checkbox" name="type[0][]" value="1" > <input type="checkbox" name="type[0][]" value="2" > <input type="checkbox" name="type[0][]" value="3" > I need to get all checked values and print them ... How can I do this? I tried the code below, but it only returns me one value Code: [Select] $values = array($_POST["type"]); foreach ($values as $item){ echo $item; } Any help??? Thanks!! Hey guys i am currently building a very complex form for one of my clients. The for has ALOT of imputs and can also generate new one automaticly using javascript. My problem is that come of them returns empty arrays while other works. Is there a maximum or some kind that a form can submit at the time? i made a print_r on the $_POST var and this is what i got (I tooke out all the other arrays but theres a lot more then what i am posting) [...] print ('<tr> <td> <input type="text" size="9" name="styleenc[]" value=""> </td> <td> <input type="text" size="9" name="couleurenc[]" value=""> </td> <td> <input type="text" size="2" name="c_y[]" value=""> </td> <td> <input type="text" size="2" name="c_a_s[]" value=""> </td> <td> <input type="text" size="2" name="c_a_l[]" value=""> </td> <td> <input type="text" size="2" name="c_a_o_s[]" value=""> </td> <td> <input type="text" size="9" name="descenc[]" value=""> <input type="hidden" size="9" name="invisible3[]" value="3"> </td> </tr>'); [...] Code: [Select] Array ( [styleenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [couleurenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_y] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_s] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_l] => Array ( [0] => [1] => [2] => [3] => [4] => ) [c_a_o_s] => Array ( [0] => [1] => [2] => [3] => [4] => ) [descenc] => Array ( [0] => [1] => [2] => [3] => [4] => ) [invisible3] => Array ( [0] => 3 [1] => 3 [2] => 3 [3] => 3 [4] => 3 ) [emplacement] => sdcwedf ) They should all have values i don't get it ... the only one that has values is invisible3 that has been manualy specified with value="3" Hi - I have an HTML form which is dynamically produced using CodeIgniter / PHP and presents products a customer has ordered. When the customer has finished changing his quantities they must now submit the form. My problem is that my form will contain many of the same named fields for example, 'Product ID', or 'Product Name' or 'quantity'. So now when it gets processed a typical post array like product id could look like this: Code: [Select] Array ( [0] => 28 [1] => 24 [2] => 101 [3] => 23 [4] => 17 ) Of course I get an error: Quote Severity: Notice Message: Array to string conversion Filename: mysql/mysql_driver.php I really need some advice on how I should pre-process the various POST arrays so I can get them into my DB. A very grateful student of PHP ! Thanks |