[thelist] need guidance on arrays and loops in PHP

Jeremy Weiss eccentric.one at gmail.com
Thu Mar 27 12:37:11 CDT 2008


I have to write a script to process some values that could have been
submitted via several different forms. One of the values, has the
potiential to be an array. If that value is there, then it's going to
be a number that  happens to be a primary key for a table in a MySQL
db. Up to this point, things seem fairly simple. But the record that
key goes to will be something like:

id (pk) | lo_id (fk) | la_id (fk) | bla bla bla 30+ other fields

If it's just one value in the array, then there's no problem. But if
it's more than one, then I have to pull the lo_id and la_id fields and
IF those match for each value in the array, then I'll do one thing.
However, if even one of the values doesn't match then I do something
totally different.

So I'm thinking a simple  foreach (array_expression as $value)
would let me loop through and run the SELECT statements to pull the
values of lo_id and la_id for each key in the array. But where do I
store them  (the values of lo_id and la_id) so that I can compare them
to what is turned up on the other searches? Or, do I just run through
on the first one, and then make the comparisons in the foreach loop?

-jeremy



More information about the thelist mailing list