$POST with WHILE loop checkboxes

Hi there,

Wondering if anyone can help me.

I need to be able to insert the vaules of a set of While loop generated checkboxes (that are checked of course) into one row in a table. Multiple boxes can be checked

So far I have this.

My While loop:

[php]<?php
$currentqry = mysql_query(“SELECT * FROM listings WHERE uid = ‘$currentuser’”);

while($row = mysql_fetch_array($currentqry))
{
echo ’

  •  ‘.$row[‘title’].’

  • ’;
    }

    ?>[/php]

    and my submit/inset script:

    [php]include(“config.inc.php”);

    $buy = $_POST[‘buylist’];
    $buylist = array($buy);

    foreach($buylist as $key)
    {
    $allkey = $key . ", ";
    }

    $rallkey = substr($allkey, 0, -2);

    // connect to the mysql server
    $link = mysql_connect($server, $db_user, $db_pass)
    or die ("Could not connect to mysql because ".mysql_error());

    // select the database
    mysql_select_db($database)
    or die ("Could not select database because ".mysql_error());

    $offer = mysql_query(“INSERT INTO offers(id, sellerid, sellerlistid, buyerid, buyerlistid, buyercustom, sellercustom, accepted, pending, time) VALUES (NULL,’$selluser’,’$sellid’,’$buyuser’,’$rallkey’,’$_POST[cash]’,‘empty’,‘0’,‘1’,NULL)”) or die('Query failed: ’ . mysql_error() . “
    \n$sql”);

    echo header(“Location:account.php?u=”.$_SESSION[‘username’]);
    [/php]

    I’ve used the variable $rallkey at this stage for the insert to my table.

    Thanks in advance

    Sponsor our Newsletter | Privacy Policy | Terms of Service