It will probably work, and you could find out for sure by just trying it.
It might be better to construct a single query using things like:
$company_ids = implode(', ', $_POST['reporton_company']);
$query .= WHERE company_id IN ($company_ids) ;
This presumes you have already validated the
foreach($_POST['reporton_company'] as $cmp_ind =$arrayd_cmp_id) {
foreach($_POST['report_period'] as $rep_ind =$arrayd_per_id) {
foreach($_POST['questions_groups'] as $group_ind =
$arrayd_group_no) {
mysql_select_db($database_name, $dname);
Why
Not working.
foreach($_SESSION['skills'] as $key = $skill)
{
$query = INSERT INTO table (skill, sky, sku)
VALUES ('$skill',
{$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]});
//run query
}
The foreach is generating an invalid argument.
I'm just going to show again what I have
Felenstein [mailto:[EMAIL PROTECTED]
Sent: 18 October 2004 08:24
To: John Holmes; [EMAIL PROTECTED]
Subject: Re: [PHP] Nested foreach ?
Not working.
foreach($_SESSION['skills'] as $key = $skill)
{
$query = INSERT INTO table (skill, sky, sku)
VALUES ('$skill',
{$_SESSION['skys'][$key
Wish I had better news.
Warning: Invalid argument supplied for foreach() in
/home/lurkkcom/public_html/TestMultiTrans2.php on line
90
INSERT INTO LurkProfiles_Skicerts (ProfileID,
SkilCerts, NumYear, Lused) VALUES ()
line 90: foreach($skills as $key = $skill)
To confirm :
I changed to this:
to by several clients.
HTH
Graham
-Original Message-
From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
Sent: 18 October 2004 09:37
To: Graham Cossey; [EMAIL PROTECTED]
Subject: RE: [PHP] Nested foreach ?
Wish I had better news.
Warning: Invalid argument supplied for foreach
Guess what , it's working !
The key (after yours and John's iteration lines)
was adding these into the script:
$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];
A big thank you! to all who helped out here and for
hanging in.
Graham, thank you for continuing
On Sun, 2004-10-17 at 09:53 -0700, Stuart Felenstein wrote:
I have 3 arrays. 3 for 3 fields in a table (all part
of 1 record)
array1 - field1
array2 - field2
array3 - field3
What I've been doing which works good with one array:
if ( is_array( $_SESSION['foo'] ) ) {
foreach (
Robby
Here is the printout :
Using-
print_r ($skills);
print_r ($skys);
print_r ($slus);
Array ( [0] = skillone [1] = skilltwo [2] =
skillthree [3] = [4] = ) Array ( [0] = 2 [1] = 3
[2] = 4 [3] = [4] = ) Array ( [0] = [1] = [2] =
[3] = [4] = ) 1
FYI - The skills is a string, skys and slus
On Sun, 2004-10-17 at 12:40 -0700, Stuart Felenstein wrote:
Robby
Here is the printout :
Using-
print_r ($skills);
print_r ($skys);
print_r ($slus);
Array ( [0] = skillone [1] = skilltwo [2] =
skillthree [3] = [4] = ) Array ( [0] = 2 [1] = 3
[2] = 4 [3] = [4] = ) Array ( [0] = [1] =
They are related in the sense that they are part of
one record in the database.
Fields
Skill YearsUsed LastUsed
When you say array of arrays you are referring to a
multi-dimensional ? I'm not sure what you mean by
are the [0] related.
Thank you,
Stuart
--- Robby Russell [EMAIL PROTECTED]
On Sun, 2004-10-17 at 13:08 -0700, Stuart Felenstein wrote:
They are related in the sense that they are part of
one record in the database.
Fields
Skill YearsUsed LastUsed
When you say array of arrays you are referring to a
multi-dimensional ? I'm not sure what you mean by
are the
Okay, I will try -
I have these three fields in a form for user input.
There are 10 sets of these, i.e. Users can enter three
sets of skills, with the yearsused and when last used.
I have set them up as arrays, since it's probably not
wise to manage 30 seperate variables.
I'm using session
Stuart Felenstein wrote:
Here is the printout :
Using-
print_r ($skills);
print_r ($skys);
print_r ($slus);
Array ( [0] = skillone [1] = skilltwo [2] =
skillthree [3] = [4] = ) Array ( [0] = 2 [1] = 3
[2] = 4 [3] = [4] = ) Array ( [0] = [1] = [2] =
[3] = [4] = ) 1
FYI - The skills is a string,
John,
Sorry, I'm not trying to be unclear.
There are 3 columns in the table.
In the user form. there are 30 fields, 10 text and 20
dropdown.
The 10 text are:
$_SESSION['skills'] = $_POST['skill'];
The first dropdown is :
$_SESSION['skys'] = $_POST['sky'];
The second dropdown is:
Stuart,
Having read what you've written so far, you may want to try something
like this.
In your HTML (I've left the selects empty, but you can see what I mean):
input type=text name=skills[0][name] /select
name=skills[0][years] /select name=skills[0][used] /
input type=text
Stuart Felenstein wrote:
John,
Sorry, I'm not trying to be unclear.
There are 3 columns in the table.
In the user form. there are 30 fields, 10 text and 20
dropdown.
The 10 text are:
$_SESSION['skills'] = $_POST['skill'];
The first dropdown is :
$_SESSION['skys'] = $_POST['sky'];
The second
17 matches
Mail list logo