Hallo everyone
I am, as one might say, 'near yet so far'....

* I have a page of user subscription info generated on the fly
* I want an administrator to check a box on each result set
* The info from each checked result set should be inserted into another table (A new 
row/tuple for 
each user)

I am currently using each form element as an array to hold x number of Names, Adresses 
etc. Where 
'x' is the number of results generated, and consequently the number of checkboxes 
generated.

The processing script loops thru this and inserts only those results that have been 
checked by the 
administrator in inserted in a new row.

Using $HTTP_POST_VARS and dumping that to the page displays (obviousely) 'array', 
'array', etc. 
As each hidden form element is an array and also an $HTTP_POST_VARS element)
I need some way to extract the value of each array's keys so that they can be used in 
an SQL INSERT.

I'm using MySQL-3.22.32 and php4.0.3pl1

Here is what I have as the processing script, but as you should be able to see it is 
immedietley 
very limiting:

while (list($key,$val) = each($Name)) {
    $insertsql = "INSERT INTO $table_user (Name) VALUES ('$val')";
    $result = mysql_query($insertsql, $connection) or die(mysql_error());
    }

This simply INSERTS the values in the Name array, into a new row for each name held in 
the array. 
Is it possible to somehow extend this loop or use a different kind of loop to insert 
all the array 
values in this manner?

Ideally it would work like this (This is JUST to illustrate the point, I KNOW it won't 
work!!)

while (list($key,$val) = each($Name,$Address,$Age,$Course)) {
    $insertsql = "INSERT INTO $table_user (Name,Address,Age,Course) VALUES 
    ('$valName','$valAddress','$valAge','$valCourse')";
    $result = mysql_query($insertsql, $connection) or die(mysql_error());
    }

Can anyone make any suggestions that would help me here?
Many thanks in advance!
Russ

#-------------------------------------------------------#
                                
  "Believe nothing - consider everything"       
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com
                        
#-------------------------------------------------------#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to