473,385 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2116
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
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...
1
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...
5
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...
6
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...
6
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...
9
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...
1
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
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...
7
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.