RE: [PHP] arrays and sessions

2004-02-27 Thread Chris W. Parker
Kermit Short mailto:[EMAIL PROTECTED]
on Friday, February 27, 2004 1:47 PM said:

 A second form will contain an action that
 sends the sql code for creating the table to the database server, and
 viola, I've got myself a new table.

i prefer the violin, but viola's are cool too. ;)

 If anyone has any
 suggestions on how I can get this done I'd appreciate it!

wait.. i don't understand. you're asking us for a method to accomplish
what you describe or are you looking for help with a problem you're
having?? if the former, your method *sounds* ok to me. if the latter
please post the error you're getting.

 I'd really
 rather not post my whole code file, as it's really big and long, and
 emphasizes how novice I am at PHP.

good choice.


 Thanks in advance for your help!

no problem.


 -Kermit

is your real name Kermit?




chris.

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



Re: [PHP] arrays and sessions

2004-02-27 Thread Kermit Short
I've got some code and it simply isn't working.  I thought it might be
because each time the form submits data, the array I'm storing information
in is being re-initialized.  If this is the case, I don't have the
multidimensional array I'm trying to get, but just a vector array with the
most recent submission data.  I tried making the array a session variable,
but I'm not even sure the session part of it is working.  So, if you have
any methods that you think might work better than what I'm trying to do, I'd
love to hear about it.  Basically, my file is structured like this:

1. Pull in POST data, and store them in php variables
2. If the POST data is null, display the first form and get the table name,
field name, field type, primary key, and null allowed information.  On
submit, the information is stored in an array.
3. If the POST data is not null, again display the entry form in case the
user needs to add more fields, and step through the array to display the
existing table info that the user has already entered.  A button in a second
form is also displayed.  When clicked, it actually creates the table.

My problems are that when I try to step through the array and display its
current contents, I get index not defined errors on my for loop indices
(?!).  The second problem is, when I try to use the print_r function to
display my array, it only displays one set of data.  This might be because
I'm trying to do a C++ type 2 dimensional array concept when PHP arrays are
associative by nature, and I'm not sure how to get around this.
Suggestions?

(Yes, Kermit is my real name.  Miss Piggy is well, and sends her regards.)

-Kermit

Chris W. Parker [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Kermit Short mailto:[EMAIL PROTECTED]
on Friday, February 27, 2004 1:47 PM said:

 A second form will contain an action that
 sends the sql code for creating the table to the database server, and
 viola, I've got myself a new table.

i prefer the violin, but viola's are cool too. ;)

 If anyone has any
 suggestions on how I can get this done I'd appreciate it!

wait.. i don't understand. you're asking us for a method to accomplish
what you describe or are you looking for help with a problem you're
having?? if the former, your method *sounds* ok to me. if the latter
please post the error you're getting.

 I'd really
 rather not post my whole code file, as it's really big and long, and
 emphasizes how novice I am at PHP.

good choice.


 Thanks in advance for your help!

no problem.


 -Kermit

is your real name Kermit?




chris.

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



RE: [PHP] arrays and sessions

2004-02-27 Thread Chris W. Parker
Kermit Short mailto:[EMAIL PROTECTED]
on Friday, February 27, 2004 2:10 PM said:

 I've got some code and it simply isn't working.  I thought it might be
 because each time the form submits data, the array I'm storing
 information in is being re-initialized.  If this is the case, I don't
 have the multidimensional array I'm trying to get, but just a vector
 array with the most recent submission data.

here are some thoughts...

sounds like you're just not keeping track of each iteration. i mean,
within the session variable you need to somehow differentiate between
each subsequent form submittal.

?php

  $iteration = ++$_POST['iteration'];

  $_SESSION['post_data'][$iteration] = $_POST;

  // include $iteration in the post data
  // so that next time it comes around
  // it can be incremented.
  echo QQQ

form method=post action=myself
 ...
 input type=hidden name=iteration value=$iteration /
 ...
/form

?

you should then see a multi-dimensional array with
'print_r($_SESSION);'.

this code is untested and not very complete. ;) but maybe it will give
you some ideas?


hth,
chris.

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



Re: [PHP] arrays and sessions

2004-02-27 Thread Justin Patrin
First of all, make sure you're doing session_start() before 
reading/writing any session data and before you do any output.

Second, You likely need to just do something like this:

session_start();
if(post data) {
  $_SESSION['formArray'][] = $_POST;
}
This will save each POST array as-is in the session.

Chris W. Parker wrote:

Kermit Short mailto:[EMAIL PROTECTED]
on Friday, February 27, 2004 2:10 PM said:

I've got some code and it simply isn't working.  I thought it might be
because each time the form submits data, the array I'm storing
information in is being re-initialized.  If this is the case, I don't
have the multidimensional array I'm trying to get, but just a vector
array with the most recent submission data.


here are some thoughts...

sounds like you're just not keeping track of each iteration. i mean,
within the session variable you need to somehow differentiate between
each subsequent form submittal.
?php

  $iteration = ++$_POST['iteration'];

  $_SESSION['post_data'][$iteration] = $_POST;

  // include $iteration in the post data
  // so that next time it comes around
  // it can be incremented.
  echo QQQ
form method=post action=myself
 ...
 input type=hidden name=iteration value=$iteration /
 ...
/form
?

you should then see a multi-dimensional array with
'print_r($_SESSION);'.
this code is untested and not very complete. ;) but maybe it will give
you some ideas?
hth,
chris.


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