Solved

PHP next field

Posted on 2014-02-18
5
304 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 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
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
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
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
Comment Utility
Thanks for the assist... got it now.
0
 
LVL 108

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now