[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

PHP next field

Posted on 2014-02-18
5
Medium Priority
?
366 Views
Last Modified: 2014-02-18
I use the code below to find certain fields:

***********
foreach ($_REQUEST as $theField => $Data){
      if (substr($theField,strlen($theField)-5,5) == "O~U~T"){
            if (is_numeric($Data * 1)){
                  if ($Data > 0){
                        echo $theField . " - " . $Data . "<br>";
                  }
            }
      }
}
***********
In my form, next to each O~U~T field is an I~N and S~O~L~D field.
I'd like to do something like this:
                        echo TheNextField . " - " . TheNextFieldsData . "<br>";
                        echo TheFieldAfterThat . " - " . TheNextFieldAfterThatData . "<br>";

How can I accomplish this please?
0
Comment
Question by:classnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39867304
The foreach() statement contains two variables; these are the key and the data elements. Foreach is used to iterate over arrays and objects.  There are two kinds of array keys in PHP, index keys that are numeric and associative keys that are character strings.  The $_REQUEST superglobal variable is an associative array, so the keys are character strings.  That makes it difficult to use a numeric index to point to the "next" element of the array.

Here is what you might want to do:  Post a link to the web page that has the form, and post the actual PHP script that processes the form.  You can obscure passwords and such, but do not obscure any of the HTML or PHP code.  Armed with that information we may be able to help you get what you need.
0
 

Author Comment

by:classnet
ID: 39867321
Thanks... all I'm trying to do is to push this data into a db.  

The form contains, at least, many rows that have an O~U~T, I~N  and S~O~L~D column.

In one "insert" statement I want to push the three values.

This page is being converted from asp.  In asp the page referenced Request.Form.Item(intLoop).  intLoop checked for the O~U~T field

The sql statement used Request.Form.Item(intLoop), Request.Form.Item(intLoop + 1) and Request.Form.Item(intLoop + 3)
*NOTE Request.Form.Item(intLoop + 2) is a field that we don't need to push.

I am just trying to minimize the re-write...
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39867585
Thanks for the description.  Let me try this request again, please.
Post a link to the web page that has the form, and post the actual PHP script that processes the form.  You can obscure passwords and such, but do not obscure any of the HTML or PHP code.  Armed with that information we may be able to help you get what you need.
0
 

Author Closing Comment

by:classnet
ID: 39867724
Thanks for the assist... got it now.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39868275
Great - glad you've got it working.  Thanks for using EE, ~Ray
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question