Hi all + Rick:

Since the last email I have got even closer, here is the code:

//If submit button selected, process those ticked checkbox categories:
if(isset($submit)) {
        //Start off sql
        $sql = "INSERT INTO $myanet02 (";
        //loop while categories have been ticked
        while(list($key,$val) = each($category)) {
                if($val != 'yes') { 
                        $sql1 .= "$key,";
                        $sql2 = substr($sql1,0,-1) . ")";
                        $sql3 .= "'NULL',";
                        $sql4 = $sql . $sql1 . $sql2 . "VALUES (" . $sql3;
                else {
                        $sql1 .= "$key,";
                        $sql2 = substr($sql1,0,-1) . ")";
                        $sql3 .= "'$email',";
                        $sql4 = $sql . $sql1 . $sql2 . "VALUES (" . $sql3;
//Remove the last comma
$sql = substr($sql4,0,-1) . ")";
//$query = mysql_query($sql,$connect) or die(mysql_error());
echo $sql;

However, this returns the following echoed SQL query:
INSERT INTO myanet_categories (staffdev ,staffdev )VALUES ('[EMAIL PROTECTED]') 

This is almost correct, in that I only selected a single category to INSERT INTO (a 
single email 
being the inserted value). But as you can see, that category has been repeated in the 
list of 
fields to be inserted into. If I select say, 3 categories, then this is what happens:

INSERT INTO myanet_categories (staffdev ,rules ,policies ,staffdev ,rules ,policies )

See what I mean?
If anyone has any other pointers I would be more than happy to receive them!!


  "Believe nothing - consider everything"       
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  w: www.apu.ac.uk/webteam


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