Solved

PHP next field

Posted on 2014-02-18
5
316 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
  • 3
  • 2
5 Comments
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 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 109

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 109

Expert Comment

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

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

777 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