www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] for each array problem

  1. #1
    Join Date
    Mar 2008
    Posts
    88

    resolved [RESOLVED] for each array problem

    Hey peeps,

    I have a form which has checkboxes and textboxes.

    Im trying to make a for each to duplicate all the data appart from one cell and make a new insert for every checkbox that has been checked:

    for each checkbox that has been checked insert into the database. so it'll look something like this

    col1 col2 col3
    1 2 3
    1 2 5
    1 2 9

    Here how far its come:

    PHP Code:

        <?php 
            
    echo '<p> post places: ' $_POST['place'] . '</p>';
            
    $places_array explode (',' $places);
            echo 
    '<p> places array: ' print_r($places_array) . '</p>';
            
            foreach(
    $places_array as $place_entry){
                
    str_replace("\'"""$place_entry$count);
                echo 
    $place_entry;
                echo 
    $count;
            }
            
        
        
    $insert "INSERT INTO activities (`date`, `email`, `place`) VALUES ('".$daf."','".$email."','".$place_entry."','")";
    $add_activity = mysql_query($insert);
    if(
    $add_activity == false) {
        
    $error = mysql_error();
        die("
    <pre>".$error."\n$insert</pre>");


    ?>
    This is what it prints out

    post places: elm, fir

    Array ( [0] => elm [1] => fir )
    places array: 1

    elm0 fir0

    How would you make this work?

  2. #2
    Join Date
    Mar 2008
    Posts
    88
    I made it insert into the database the way i want BUT it leaves all the other fields blank HELP

    THanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles