[PHP] Submit Button Refresh Problem?

2004-01-05 Thread wknit
I have a php file that contains all the functions that I run on the page
that is displayed, self-contained.

The main function is ? makeArrays(); ?

I am invoking that function with a Submit button OnClick event.

Whenever I click the button, the page refreshes and the function runs just
fine displaying a dynamically generated random sequence of numbers.

The problem is the page refresh itself.

When the page first loads the function runs and it shouldn't, the display
should be blank until the button is clicked.

This is a problem because I have another button that will be coded to write
the data generated to a database, at present that function is empty, however
when I click that button the page refreshes again and the number data
changes.

How do I keep the page from refreshing on load and apparently self clicking
the form button, and how do I keep the page from refreshing and running the
'makearrays' function when I click the 'writedata' function?  When the
'writedata' function is invoked from a button click only that function
should be called and the data from the previous page should be returned to
the page again (same).. i.e. the random number sequence does not change.

Thanks!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Compare Array Elements

2004-01-03 Thread wknit
I am a novice, I am sure this is pretty simple...

I have two arrays of integers, equal length.
The arrays elements consists of the integers 0 through 9.
The order of the numbers in the arrays should always be different.

Example 1: Is ok
xArray: 2 9 6 0 1 3 4 5 8 7
yArray: 3 7 1 9 0 8 6 2 4 5

Example 2: Is not ok - the element 7 is in the same position in both
arrays.
xArray: 2 9 6 0 7 3 4 5 8 1
yArray: 3 5 1 9 7 8 6 2 4 0

I need a snippet that will compare the value of each element in each
position and call a function to create a new array if the compare evaluates
to true.  I assume that a foreach is the way to go, but I can't seem to find
the right syntax for it.

---
if foreach (xArray as $x) == (yArray as $y) {
new_yArray ();
}
--

I know this isn't correct, but in idiot terms, it is what I want to do... a
test/compare.  Of course the compare should stop and call the function the
moment it evaluates to true at any given position.

Maybe I should be using a for loop? (again, not a clue)

Thanks anyone!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php