PHP - Multiple Post Values
I'm sorting out a simple PHP email form, and I would like, when the email arrives in my inbox, for it to display both the email of the sender AND their name as specified in the form on my website.
So far I have $from = $_POST['from']; with the 'from' being the client's email address. I would also like their name ('name') to show up next to their email in the header. I have tried such things like $from = $_POST['from' . 'name']; //or $from = $_POST['from']; $_POST['name']; and a few more, but I'm terrible at PHP coding in general. I have searched, but I really am at a loss as to what to search for. Can someone please give me an idea as to what I should do? Thanks, Sacha. Similar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
Hi guys, I am trying to create a script that gets a multiple select form selections and assign them to variables with php via the POST method. This is my code: Code: [Select] <select name="search_commodity[]" multiple="multiple" size="3" style="position:absolute; top:80px; left:414px; " > <option value="all">All</option> <option value="none">None</option> <option value="some">Some</option> </select> Then after the form gets submited then it should go to this php page and the first value of the chosen options has to be assigned to the variable called commo. The problem is that is is not assigning anything. Code: [Select] <?php $commo = $_POST['search_commodity[0]']; ?> Can someone help please? I can't figure it out. Hi, My company has 240+ locations and as such some users (general managers) cover multiple sites. When I run a query to pull user information, when the user has multiple sites to his or her name, its adds the second / third sites to the next columns, rather than wrapping it inside the same table cell. It also works the opposite way, if a piece of data is missing in the database and is blank, its pull the following columns in. Both cases mess up the table and formatting. I'm extremely new to any kind of programming and maybe this isn't the forum for this question but figured I'd give it a chance since I'm stuck. The HTML/PHP code is below: <table id="datatables-column-search-select-inputs" class="table table-striped" style="width:100%"> <thead> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> <th>Actions</th> </tr> </thead> <tbody> <?php //QUERY TO SELECT ALL USERS FROM DATABASE $query = "SELECT * FROM users"; $select_users = mysqli_query($connection,$query);
// SET VARIABLE TO ARRAY FROM QUERY while($row = mysqli_fetch_assoc($select_users)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_phone = $row['user_phone']; $user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id'];
// POPULATES DATA INTO THE TABLE echo "<tr>"; echo "<td>{$user_id}</td>"; echo "<td>{$user_firstname}</td>"; echo "<td>{$user_lastname}</td>"; echo "<td>{$username}</td>"; echo "<td>{$user_phone}</td>";
//PULL SITE STATUS BASED ON SITE STATUS ID $query = "SELECT * FROM sites WHERE site_manager_id = {$user_id} "; $select_site = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($select_site)) { $site_name = $row['site_name']; echo "<td>{$site_name}</td>"; } echo "<td>{$user_title_id}</td>"; echo "<td>{$user_role_id}</td>"; echo "<td class='table-action'> <a href='#'><i class='align-middle' data-feather='edit-2'></i></a> <a href='#'><i class='align-middle' data-feather='trash'></i></a> </td>"; //echo "<td><a href='users.php?source=edit_user&p_id={$user_id}'>Edit</a></td>"; echo "</tr>"; } ?>
<tr> <td>ID</td> <td>FirstName</td> <td>LastName</td> <td>Username</td> <td>Phone #</td> <td>Location</td> <td>Title</td> <td>Role</td> <td class="table-action"> <a href="#"><i class="align-middle" data-feather="edit-2"></i></a> <a href="#"><i class="align-middle" data-feather="trash"></i></a> </td> </tr> </tbody> <tfoot> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> </tr> </tfoot> </table>
Is there a quick an easy way to test my php scripts without creating an html form and specifying values that I post to my php script? Maybe a firefox plugin or some tool that can be used to do it quicker? In the long haul, quicker, not just one time Hi, I am fairly new to PHP and I have built a page which accepts values from dynamically added rows so there is a combination of HTML,Javascript and PHP in the process. I am caught up with a problem HTML section In my form I have a table with a column as below and a dynamic "Add Row" which would increment the row in javascript and assign a new value to the input name as txtRow2,txtRow3,txtRow4 and so on based on the number of iteration " <tr><td><input type="text" name="txtRow1" id="txtRow1" size="40" /></td></tr> <input type="button" value="Add Row" onclick="addRow();" />" Javascript section The below code generates the new row in js var cellRight2 = row.insertCell(1); var e1 = document.createElement('input'); e1.type = 'text'; e1.name = 'txtRow1' + iteration; e1.id = 'txtRow1' + iteration; e1.size = 20; cellRight1.appendChild(e1); I hope you have understood what I have done till above.. Now comes the problematic part PHP section( I love PHP ) I have to insert the column values into mysql and i will do this using a for loop within which I will have my insert statement INSERT INTO test values($txtRow) Lets say I added 4 rows dynamically with values held in $txtRow1,$txtRow2,$txtRow3,$txtRow4(See the java script section) how would I use these values in my PHP insert statement as I don't want to write 4 different insert scripts and the following "$txtRow.i" won't work for ($i = 1; $i <= 10; $i++) { INSERT INTO test values($txtRow.i) } Any suggestions are welcome...If you think you still need to see the whole code i can post it too. Jay Hi, During post of my form I am trying to send some table values. The three field values (DATE, SITE, PRICE) that I want to send are attached to the id field (RID) in the daterange table. The variable $FTGRID is attached to the RID field. Here is the structure of the daterange table and the code from the php page related to the email is below. Do I need to pre-define variables for these three field values? daterange Table: RID DEND MONTH DATE SITE PRICE STATUS Code: [Select] if ( $validationFailed === false ) { # Email to Form Owner $emailSubject = FilterCChars("Your Reservation"); $emailBody = "Reservation Date : \n" . "Site : \n" . "Price : \n" . "Fname : $FTGFNAME\n" . "Lname : $FTGLNAME\n" . "Addr1 : $FTGADDR1\n" . "Addr2 : $FTGADDR2\n" . "City : $FTGCITY\n" . "State : $FTGSTATE\n" . "Zip : $FTGZIP\n" . "Phone : $FTGPHONE1" . "- $FTGPHONE2" . "- $FTGPHONE3\n" . "Email : $FTGEMAIL\n" . "Payment Method : $FTGPM\n" . "Last Four CC : $FTGC4\n" . ""; $emailTo = 'u@yahoo.com'; $emailFrom = FilterCChars("inquiry@c.com"); $emailHeader = "From: $emailFrom\n" . "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=\"UTF-8\"\n" . "Content-transfer-encoding: 8bit\n"; mail($emailTo, $emailSubject, $emailBody, $emailHeader); # Confirmation Email to User $confEmailTo = FilterCChars($FTGEMAIL); $confEmailSubject = FilterCChars("Confirmation of Reservation"); $confEmailBody = "Reservation Date : \n" . "Site : \n" . "Price : \n" . "Fname : $FTGLNAME\n" . "Lname : $FTGLNAME\n" . "Addr1 : $FTGADDR1\n" . "Addr2 : $FTGADDR2\n" . "City : $FTGCITY\n" . "State : $FTGSTATE\n" . "Zip : $FTGZIP\n" . "Phone : $FTGPHONE1" . "- $FTGPHONE2" . "- $FTGPHONE3\n" . "Email : $FTGEMAIL\n" . "Payment Method : $FTGPM\n" . "Last Four CC : $FTGC4\n" . ""; $confEmailHeader = "From: inquiry@c.com\n" . "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=\"UTF-8\"\n" . "Content-transfer-encoding: 8bit\n"; mail($confEmailTo, $confEmailSubject, $confEmailBody, $confEmailHeader); Hi, I have a form for news articles. It has a title and a body which is fine. I also have a search box that allows the user to search for a memeber and click their name when it appears. This moves a div with a data-id into another div. The purpose of this is to tag them in the article. I am able to post all of the simple stuff but how would i post these value. I am assuming that i would need to create an array of said values but i am struggling to get them showing in post at all. Here is the code i have so far <?php function searchForPeople($searchVal, $exclude = '0'){ $sv1 = $searchVal; $sv2 = $searchVal; include 'includes/dbconn.php'; $out =""; $stmt = $conn -> prepare(" SELECT fname, lname, id FROM person WHERE id NOT IN (".implode(',', array_map('intval', $exclude)).") AND (fname LIKE CONCAT('%',?,'%') OR lname LIKE CONCAT('%',?,'%')) "); $stmt -> bind_param('ss', $sv1, $sv2); $stmt -> execute(); $stmt -> bind_result($fn, $ln, $pid); while($stmt -> fetch()){ $out .= "<div class='btn btn-primary m-1 tagInArticle' name='taggedPerson[]' data-id='$pid'>$fn $ln</div>"; } return $out; } ?> ...... <div id="searchResultsHere"> <!-- ajax content here --> </div> <hr> <div id="taggedInArticleContainer"> <!-- ajax content here --> </div> ....... <div class="col-lg-2"> <button type="submit" name="PublishNewNews" class="btn btn-primary w-100 mb-3">Publish</button> <button class="btn btn-primary w-100">Save</button> <hr> <div class="btn btn-warning w-100 mb-3">Private</div> <input type="hidden" name="howVisible" value="Private"> <hr> <p class="text-justify">Private news articles will only be avilable to logged in users</p> </div> ....... <script> $('#searchResultsHere').on('click', '.tagInArticle', function tagInArticle(){ var tagButton = $(this); tagButton.appendTo('#taggedInArticleContainer') }); $('#searchForPeopleBox').keyup(function(){ var searchVal = $(this).val() var tagged = '0' var tagged = $('#taggedInArticleContainer').find('.tagInArticle').map(function(){ return $(this).data('id'); }).get(); $.ajax({ type: 'post', data: {"ajax" : 'one', "val" : searchVal, "exclude" : tagged}, success: function(resp){ $('#searchResultsHere').html(resp) } }) }); </script> I hope this is enough to go on. I am sure it is simple but i just cant get it. Thanks all in advance. When i click my submit button i am posting the following. Array ( [submitStaffOrder] => [staffMember] => Array ( [0] => 2 [1] => ANYCHEF1 ) [date] => Array ( [0] => 2020-02-18 [1] => 2020-02-18 ) [startTime] => Array ( [0] => 11:01 [1] => 10:10 ) [finishTime] => Array ( [0] => 11:01 [1] => 10:01 ) [delExisting] => Array ( [0] => [1] => toDel ) ) I would like to update/insert if delExisting is blank and delete if it has toDel in there. I have the following but i am pretty sure the if is not working. $date = $_POST['date']; $stime = $_POST['startTime']; $ftime = $_POST['finishTime']; $del = $_POST['delExisting']; $staff = $_POST['staffMember']; $stmt = $conn -> prepare(" INSERT IGNORE INTO ssm_staff_order (job_id, staff_id, staff_start_time, staff_finish_time, staff_start_date, staff_finish_date) VALUES (?,?,?,?,?,?) ON DUPLICATE KEY UPDATE staff_start_time = VALUES(staff_start_time), staff_finish_time = VALUES(staff_finish_time); "); $delstmt = $conn -> prepare(" DELETE FROM ssm_staff_order WHERE staff_id = ? AND job_id = ? AND staff_start_date = ? "); foreach ($staff as $key => $staffId) { if ($del == '') { $start = $date[$key].' '.$stime[$key]; $finish = $date[$key].' '.$ftime[$key]; $stmt -> bind_param('isssss', $jid, $staffId, $start, $finish, $date[$key], $date[$key]); $stmt -> execute(); } if ($del == 'toDel') { $delstmt -> bind_param('sis', $staffId, $jid, $date[$key]); $delstmt -> execute(); } } } Can i do what i am trying to do or am i way off here?
I struggle with arrays Edited February 24, 2020 by AdamhumbugHi I have a form that is to input data from input fields to a table. The form is as follows: $query = $DB->query("SELECT country_code, country_id, IF(country_code = '".$country_code."', '', '') AS sel FROM exp_sme_countries WHERE site_id='".$this->settings['site_id']."' ORDER BY country_name ASC"); foreach ($query->result as $row) { $options .= '<label>' . 'Phrase for ' . $this->settings['countries'][$row['country_code']] . '</label>' . '<br />'; $options .= '<input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_id[]" />' . '<br /><br />'; $options .= '<input type="hidden" name="country_data[' . $row['country_id'] . ']" value="'.$row['country_id'].'" />'; } This outputs: Code: [Select] <input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_id[]" /> <input type="hidden" name="country_data[68]" value="68" /> <input style="width: 100%; height: 5%;" id="country_data" type="text" name="country_id[]" /> <input type="hidden" name="country_data[28]" value="28" /> What I need to do, is get the values from the input fields and then match them with the correct hidden field value So if in the first input field, I typed in 'Test data' and the second input, i typed 'This is great' On the POST, I need to find the the value ('Test data') and also the value from the hidden field. So something like: Quote The text you entered is: Test data with hidden value of 68 The text you entered is: This is great with hidden value of 28 I'd rather not use $_GET as this is a form that inserts data into a database. Could someone point my in the right direction or provide an example? I am having trouble with passing values with a POST to another php file. I am getting the error : undefined index : productID and undefined index: filename. I have also tried : <form method = \"POST?pdib=$processID&filename=$filename\" action = \"upload2.php\" > When I look at the array of superglobals, they are both defined. Thank you! Here is the code : drawfirsttwoforms: $sql = "SELECT ProductFilename, ProductName, ProductID, ProductDescription,ProductCost,ProductQuantity, ProductCatTitle FROM products INNER JOIN customers ON customers.CustomerID = products.CustomerID WHERE ((products.ProductKeyWord1 = ?) OR (products.ProductKeyWord2 = ?) OR (products.ProductKeyWord3 = ? )) AND (products.ProductCatTitle = ?) "; $stmt = $dbo->prepare($sql); $stmt->bindParam(1, $keyword1); $stmt->bindParam(2, $keyword1); $stmt->bindParam(3, $keyword1); $stmt->bindParam(4, $titleOfSelectedDropDown); $stmt->execute(); while ($row = $stmt->fetch()) { //these variables do have values here $productID = $row['ProductID']; $filename = $row['ProductFilename']; $string1 .= " <div class = \"A\" id = \"$mainDiv\"> <p id = \"link1\">product id :$productID</p> <p>category id :$category</p> <div class = \"A\" id = \"endz\"></div> <div class = \"A\" id = \"startz\"></div> <div class=\"container\"> <div id = \"testing\" >testing <div> <div id = \"$displayID\" > </div> <div class=\"row\" > <div class=\"col\"> <form method = \"POST\" action = \"upload2.php\" > <input type=hidden id='$productID' name= '$productID' value=\"A\"> <input type=hidden id=\"$filename\" name=$filename value=\"B\"> <button value = \"Submit\" type = \"submit\" >submit it</button> </form> <iframe id=\"upload_target\" name=\"upload_target\" style=\"width:0;height:0;border:0px solid #fff;\"></iframe> <img width=\"120\" height =\"120\" id = \"$imageID\" src=\"../php proj/uploads/$filename?<?php echo filemtime($filename)?>\"> <button onclick = \"imageRefresh( '{$filename}', '{$imageID}', '{$_SESSION["msg"]}' )\" >Display</button> </div> AFTER: if (!isset($myObj) && isset($string1)) { $myObj = new stdClass(); $myObj->htmlstuff = $string1; //Encode the data as a JSON string $jsonStr = json_encode($myObj); echo $jsonStr; }
function printHTML1(keyword){ const element = document.getElementById("dropDown1"); //const checkValue = element.options[element.selectedIndex].value; const checkText = element.options[element.selectedIndex].text; var val1 = checkText; var xmlhttp = new XMLHttpRequest(); var keyword1 = keyword; var url = "drawfirsttwoforms.php?keyword=" + keyword.value + "&" + "val1=" + val1; xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var jsonData = JSON.parse(this.responseText); var answerHtml = jsonData.htmlstuff; document.getElementById("codehere").innerHTML = answerHtml; createAndModifyDivs(); } }; xmlhttp.open("GET", url , true); xmlhttp.send(); }
upload2.php <?php session_start(); $productID = $_POST['productID']; $filename = $_POST['filename'];
I'm using the following script: http://jsfiddle.net/VzVy6/8/ It give a alert message that slide in/out when a required field is still empty on submit. The script works fine, and in this example its only one field. When the field is empty I see the fade in alert message, and when the field has been filled in I see a normal popup alert message: alert("Would be submitting form"); I can't get it to work to change this alert message to a page POST submit. I was looking online, and I see Ajax examples that I don't get to work. What I want is that when all fields are filled in, that the form POST submit to another page including the values in the textboxes ofcourse. Maybe its something really easy, but I have already a headache because tried to get it to work for more then 5 hours in a row. Thank you for your time. It's been a while since I've needed to whip anything substantial up from scratch, so my scripting is a little (lot) fast and loose (weird/inefficient) here. I'm trying to mock up a script that's essentially a quiz/survey. There are a handful of topics, each with a few screens of yes/no questions. At the end, it returns a list of recommendations based on the answers gathered. The script is posting back to itself. Using print_r ($_SESSION), it seems like all of the post values for the first screen of questions are being assigned to the session array as expected. When the second screen of questions is answered, their values are assigned as well, but the values for the first set go away completely. This continues through subsequent screens, with the values from the previous screen present and all others before missing. I'd really appreciate a look at my code to see if you tell me the cause or error(s). Thanks! <?php session_start; include('_config.php'); // database connect $dbc = mysqli_connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); // set to section 1, page 1 if no values are in _POST array if (($_SERVER['REQUEST_METHOD'] == 'GET') || (!isset($_POST['section']))) { $section = 1; $page = 1; } else { // something was posted, so...set those values in session variable foreach($_POST as $key => $data) { $_SESSION[$key] = $data; } // debug: display contents of the session array print_r ($_SESSION); // which section and page? $section = (int) $_POST['section']; $page = (int) $_POST['next']; } // check if last topic $query = "SELECT * FROM hw_topics"; $data = mysqli_query($dbc, $query); if ($section == mysqli_num_rows($data)) { $last_section = true; } else { $last_section = false; } // get current topic name and info $query = "SELECT topic, display_name, pages_in_topic FROM hw_topics WHERE topic_id = '$section'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { $row = mysqli_fetch_array($data); $topic_display_name = $row['display_name']; $pages_in_topic = $row['pages_in_topic']; } // test if last page in topic $topic_pages = $row['pages_in_topic']; if ($page == $topic_pages) { $last_page_in_section = true; } else { $last_page_in_section = false; } // set form action (set to this script or to recommendations when last section is complete if (($last_section == true) && ($last_page_in_section == true)) { $form_action = $CFG->reccomend; } else { $form_action = $_SERVER['PHP_SELF']; } // get current page headline $query = "SELECT page_headline FROM hw_pages WHERE topic_id = '$section' AND page_number = '$page'"; $data = mysqli_query($dbc, $query); if (mysqli_num_rows($data) == 1) { // The headline row was found so display the headline $row = mysqli_fetch_array($data); $page_headline = '<h2>' . $row['page_headline'] . '</h2>'; } // Grab the question data from the database to generate the list and form fields $query = "SELECT question_id, question_number, question_text FROM hw_questions WHERE topic_id = '$section' AND page_id = '$page' ORDER BY question_number"; $data = mysqli_query($dbc, $query); $questions = array(); while ($row = mysqli_fetch_array($data)) { array_push($questions, $row); } include($CFG->includesdir.'/header.php'); ?> <div id="head"> <h1>Assessment<?php if (isset($topic_display_name)) { echo ': <em>' . $topic_display_name . '</em>'; } ?></h1> <p class="paging">Page <?php echo $page; ?> of <?php echo $pages_in_topic; ?></p> </div><!-- #head --> <div id="content"> <p class="instr">Please complete this survey. We'll generate a list of recommendations and resources for your organization.</p> <div id="questions"> <?php echo $page_headline; ?> <form method="post" action="<?php echo $form_action; ?>"> <table border="0" cellpadding="0" cellspacing="0"> <thead> <tr> <td></td> <td class="qtext"></td> <td class="qanswer">yes</td> <td class="qanswer">no</td> <td class="pad"></td> </tr> </thead> <?php if ($questions) { // display question rows foreach ($questions as $question) { echo '<tr>'; echo '<td class="qnumber">' . $question['question_number'] . '.</td>'; echo '<td class="qtext"><p>...' . $question['question_text'] . '</p></td>'; echo '<td class="qanswer"><div class="radio" id="box-yes"><input type="radio" value="yes" name="qid_' . $question['question_id'] . '" id="qid_' . $question['question_id'] . '" class="radio" /></div></td>'; echo '<td class="qanswer"><div class="radio" id="box-no"><input type="radio" value="no" name="qid_' . $question['question_id'] . '" id="qid_' . $question['question_id'] . '" class="radio"'; $field_name = 'qid_' . $question['question_id']; if (isset($_SESSION[$field_name])) { echo ' checked="checked"'; } echo ' /></div></td>'; echo '<td class="pad"></td>'; echo '</tr>'; } } else { echo '<tr>'; echo '<td colspan="3" class="qtext"><p>No questions found in the database for this page.</p></td>'; echo '<td class="pad"></td>'; echo '</tr>'; } ?> </table> <ul id="controls"> <?php if ($last_page_in_section == true) { $section++; $page = 1; } else { $page++; } echo '<input type="hidden" value="' . $section . '" name="section" />'; echo '<input type="hidden" value="' . ($page) . '" name="next" />'; if (($last_section == true) && ($last_page_in_section == true)) { echo '<li><input type="submit" value="Submit Answers and Get Recommendations" name="submit" id="submit" /></li>'; } else { echo '<li><input type="submit" value="Next Page" name="submit" id="next" /></li>'; } ?> </ul><!-- #controls --> </form> </div><!-- #questions --> <?php mysqli_close($dbc); include($CFG->includesdir.'/footer.php'); ?> hi, also i have an array with this values: $a=array('111-aa-zz-4','222-aa-zz-6','333-aa-zz-5'); and i want to sort(); this array, but it must ignore the numbers behind -aa-zz- also 4,6,5 how should i do this? best regards, tastro hi i was working on a code where i need to use multiple categories for a post, i get help before to add post in multi categories, now i need help on what would be my query to do update for a multiple categories post, to insert a new post with multiple categories i used this $values = array(); foreach($_POST['categories'] as $catID) { $values[] = "($postID, $catID)"; } $sql = "INSERT INTO `relation` (`postid`, `catid`) VALUES " . implode(', ', $values); $query = $db->query($sql); so if a post had 3 categories it will add in relation table, now i wants to update that post and modify the categories, all other part is done only problem is to update this relational category table which have two columns only associated with post. i tried like this but did not work $sql = "UPDATE relation SET `catid` = " . implode(', ', $values) . " WHERE postid ='$id' "; please any help Afternoon All, I can't seem to work this problem out; I have a form that is generated from a sql list and have two inputs as follows; Code: [Select] <input type="text" name="suppliernumber[]" id="suppliernumber[]" /> <input name="snomed[]" type="checkbox" id="snomed[]" value="<?php echo $row['VPPID']; ?>" /> Both are fed to my processing files as arrays, i then run the following foreach which uses the VPPID from the post to search in a database using a where clause. The problem comes when i also need to obtain the data from the suppliernumber $_POST if any has been supplied. My php code; Code: [Select] foreach ($_POST['snomed'] as $value) { $getRecord_sql = "SELECT vmps.NM AS NM, vmpps.QTYVAL AS QTYVAL, bnf_lookup_subcatagory.BNF_SUBCAT AS BNF_SUBCAT, bnf_lookup_catagory.BNF_CAT AS BNF_CAT FROM bnf_lookup_catagory INNER JOIN bnf_vmp ON bnf_lookup_catagory.BNF_CAT = bnf_vmp.BNF_CAT INNER JOIN bnf_lookup_subcatagory ON bnf_vmp.BNF_SUBCAT = bnf_lookup_subcatagory.BNF_SUBCAT RIGHT OUTER JOIN vmps INNER JOIN vmpps ON vmps.VPID = vmpps.VPID ON bnf_vmp.VPID = vmpps.VPID WHERE VMPPS.VPPID = '$value'"; $getRecord = mssql_query($getRecord_sql); $row = mssql_fetch_array($getRecord); $nm = $row['NM']; $qtyval = $row['QTYVAL']; $BNF_SUBCAT = $row['BNF_SUBCAT']; $BNF_CAT = $row['BNF_CAT']; $SUPPLIER = $_POST['suppliernumber']; array_push($data_array, array($value, $nm, $BNF_CAT, $BNF_SUBCAT, '', $SUPPLIER, '', '1', '', '', '', '', '', '', '', '1', '', '', $qtyval)); } I can't work out how to add the suppliernumber, i know i need another foreach but can't work out how to do it. Hope someone can help. Sam How do I send multiple headers with this code? Code: [Select] <?php $postdata = http_build_query( array( 'var1' => 'some content', 'var2' => 'doh' ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents('http://example.com/submit.php', false, $context); ?> *this header: Code: [Select] User-Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16 Is is possible to give multiple values in a single checkbox? i need to have a checkbox that holds multiple values. Help Anyone.. Hi Guys, I don't know how to do this but basically I want the value of $postcode3 to equal the value of $postcodep1 aswell as $postcodep2 like this... else {$postcode3 = $postcodep1 $postcodep2;} That doesn't work... Say $postcodep1 = LS14 $postcodep2 = 2AB Then $postcode3 = LS14 2AB How do I write this in the above php code?! Thanks, S I have a form that has a list of checboxes, each checkbox has multiple values. IE. Checkbox1 has Date 1 and Cost1. Checkbox2 has Date2 and cost2 and so on. This is what I have in form. echo "<input type=checkbox name=service_id[] value=".$id."><label>".$description."</label> Date:<input type=date name=date[] value=".date('Y-m-d').">Date:<input type=number name=cost[] value=".$cost."><br>"; When i run the for loop to insert the values into a table i have this.
foreach($_POST['service_id'] as $key => $value){
The problem is that when I select certain boxes (ie, checkbox #2), it inserts Date1 and Cost1 but does use the correct service id (ie checkbox) hi i need help on posting multiple inputs in a single button...while using mysql_fetch_array here is my codes: <? $re6 = mysql_query('select username from users where course = "BSIT" and yearlevel = "FOURTH"'); ?> <br /> <h1>Post Grade</h1> <h1>IT, Fourth Year</h1> <br />Please fill the following form to send The Grade<br /> <? $n = 0; while($row = mysql_fetch_row($re6)) { echo'<form action="grade_post.php" method="post">'; echo'Recipient<span class="small">(Username)</span><input type="text" value="'.$row['username'].'" readonly="readonly" id="recip" name="recip[' . $n . ']" />'; echo'Subject<input type="text" value="'.htmlentities($otitle, ENT_QUOTES, 'UTF-8').'" id="title" name="title[' . $n . ']" />'; echo'<input type="hidden" value="FOURTH" id="year" name="year[' . $n . ']" />'; echo'<input type="hidden" value="FIRST" id="sem" name="sem[' . $n . ']" />'; echo'Grade<input type="text" id="message" name="message[' . $n . ']" ><br />'; ++$n; } ?> i get all my recipients in every input type, but when i tried to post it in my database not all of them are posted rather only one of them are posted in my database ...what i want to happen is that all of my recipients in every input type will be posted in my database with different ids'...help pls... |