473,800 Members | 2,332 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

array inverting itself

I have a list of names from some are selected to be displayed on a
form. In this form I create an array of all the displayed values. The
user can select one of them.

Note that only some of the possible names are displayed on the form.

I then want to check that the name the user selects is in the array.

I want to refer to the array on the page the "post" form is pointing
to. So I put the array in a session

$_SESSION['arr_motakt'] = $arr_motakt;

I test here with
print_r (array_values($ _SESSION['arr_motakt']));

Which prints my values correctly.

At the top of the page the "post" form points to I have this row again
after starting the session

print_r (array_values($ _SESSION['arr_motakt']));

But now it prints an inverted selection of the names, ie the ones that
were not displayed on the form.
Further explanation.
My original list
1 Anna
2 Bertil
3 Conny
4 David
5 Ethel
6 Frank
7 Gertrud
8 Harald

Names displayed on form and shoved into array.
1 Anna
5 Ethel
7 Gertrud

The user can choose 1 or 5 or 7.

When I test the array it prints correctly
1 Anna
5 Ethel
7 Gertrud

The form is posted to the next page.

I test the array on line 2 after starting session and now it says.

2 Bertil
3 Conny
4 David
6 Frank
8 Harald

There is no further code between the form page and the page I post to.

How have I managed to invert the array?

Garry Jones
Sweden

Oct 23 '07 #1
2 2127
On Oct 23, 4:57 pm, GarryJones <mor...@algonet .sewrote:
I have a list of names from some are selected to be displayed on a
form. In this form I create an array of all the displayed values. The
user can select one of them.

Note that only some of the possible names are displayed on the form.

I then want to check that the name the user selects is in the array.

I want to refer to the array on the page the "post" form is pointing
to. So I put the array in a session

$_SESSION['arr_motakt'] = $arr_motakt;

I test here with
print_r (array_values($ _SESSION['arr_motakt']));

Which prints my values correctly.

At the top of the page the "post" form points to I have this row again
after starting the session

print_r (array_values($ _SESSION['arr_motakt']));

But now it prints an inverted selection of the names, ie the ones that
were not displayed on the form.

Further explanation.
My original list
1 Anna
2 Bertil
3 Conny
4 David
5 Ethel
6 Frank
7 Gertrud
8 Harald

Names displayed on form and shoved into array.
1 Anna
5 Ethel
7 Gertrud

The user can choose 1 or 5 or 7.

When I test the array it prints correctly
1 Anna
5 Ethel
7 Gertrud

The form is posted to the next page.

I test the array on line 2 after starting session and now it says.

2 Bertil
3 Conny
4 David
6 Frank
8 Harald

There is no further code between the form page and the page I post to.

How have I managed to invert the array?

Garry Jones
Sweden
That seems pretty odd. Can you post all your code so we can take a
look?

Oct 24 '07 #2
That seems pretty odd. Can you post all your code so we can take a
look?- Hide quoted text -
Not necessary. I slept on my problem, woke up checked the code,
yippee, I had not started session on the form page and the values
being read in was from an older session on the same site. Thought it
was too odd to be true!

Oct 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2017
by: Kaptain524 | last post by:
Hello, I am using PHP 5.0.4 with Apache 2, on WinXP Pro. This behavior appears to be fundamental however, and should not be affected by platform. It would seem that there is some kind of bug in the process that creates the reference when it is being assigned to an array element within itself. If it is already referenced, it just assigns the existing reference and avoids the problem.
1
19609
by: TF | last post by:
I have a fixed array of vectors like: vector<string> a_vStr; Then I grow each vector item and use it later. Everything works fine but I am curious about following potential problem. When we grow a vector it may copy all of its elements to different memory location to accomodate the new vector size. Is it possible that at some point an element of fixed array e.g. a_vStr gets invalid or
5
3151
by: Seeker | last post by:
Newbie question here... I have a form with some radio buttons. To verify that at least one of the buttons was chosen I use the following code ("f" is my form object) : var btnChosen; for (count = 0; count <= 1; count++) { if (eval(f.RadioButtons.checked)) { btnChosen = true; }
6
2376
by: surrealtrauma | last post by:
i have a trouble about that: i want to ask user to enter the employee data (employee no., name, worked hour, etc.), but i dont know how to sort the data related to a particular employee as a group. i want to use a array object in the class but i don't know how..i am just learning the c++. So i dont know how to use class. in fact, i have writen like the following: class employee { public: employee();
6
26944
by: Irrwahn Grausewitz | last post by:
Hey, y'all. While doing some pointer experiments I encountered a problem. I know that I know the answer already, but trying to remember I just screwed up my mind. I wonder if someone would be so kind to enlighten me, please. Consider the code below; my specific questions are embedded in the comment lines:
9
1782
by: Jonathan Burd | last post by:
Greetings everyone, I have noticed a little quirk in C's array-indexing syntax. I wonder what practical purpose this little "inverting" serves to be included in the standard (it compiles fine with gcc -pedantic -Wall -std=c89 and executes properly when run). The code follows: #include <stdio.h>
1
2227
by: spalding | last post by:
Hi Does anyone know how to invert a regex in the regularexpressionvalidator. Example; RegularExpresionValidator val = new RegularExpressionValidator(); val.ID = "val";
104
17016
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from that array Could you show me a little example how to do this? Thanks.
7
6444
by: heddy | last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int Newsize); and the newsize is smaller then what the array was previously, are the resources allocated to the objects that are now thown out of the array released properly by the CLI?
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.