Hi all, it's been awhile...
my prob. I have a form to order drinks in a bar, as below.

<div class="col_left">
<h2> Order Your Drinks And Food</h2><br />
<form action="process.php" method="post" name="orders">
<table border="1" class="trapezi">
 <td><input type="checkbox" name="drink[]" value="p/c">Carlsberg 50cl</td>
 <td><input type="text" name="drinkno[]" size="2"></td>
<td><input type="checkbox" name="drink[]" value="c/half">Carlsberg 25cl</td>
 <td><input type="text" name="drinkno[]" size="2"></td>
 <td><input type="checkbox" name="drink[]" value="b/k">Keo Bottle</td>
 <td><input type="text" name="drinkno[]" size="2"></td>
 <td><input type="checkbox" name="drink[]" value="b/c">Carlsberg Bottle</td>
 <td><input type="text" name="drinkno[]" size="2"></td>
 <td><input type="checkbox" name="drink[]" value="b/w">Water 25cl</td>
 <td><input type="text" name="drinkno[]" size="2"></td>
 <td colspan="2" align="center"><input type="submit" name="submit" value="Order"></td>


the php script is so,

$db=new sqlite3('daily.sqlite');



//$db->exec("INSERT INTO lists (name,seat,drink,food,ticket,date)
//           VALUES('$name','44','$dord','$ford','$ordertime','$date')");

echo "Drink order for ".$name."<br />";
foreach($drink as $dord) {
echo $dord."<br />";

echo $ordertime;

which works to a point, but what I need to do is work it so that when it is echo'd or added to the db the
drink and qty are a pair.
I tried array_combine, but if only one or two checkboxes are checked, it throws an error.
I tried array_pad to make the arrays the same length, but of course, thay only adds to the end of the array.
any help much appreciated.

I think you coud try changing the array name attribute

<td><input type="checkbox" name="data[0][drink]" value="p/c">Carlsberg 50cl</td>
<td><input type="text" name="data[0][drinkno]" size="2"></td>

continue the index value for the next pair of input
and print


You can also try doing something like this




the above should give you two sets of array. Assuming that all items are checked and quantities were filled, the above codes will give us something like this

array(3) {
  array(5) {
    [0]=>string(3) "p/c"
    [1]=>string(6) "c/half"
    [2]=>string(3) "b/k"
    [3]=>string(3) "b/c"
    [4]=>string(3) "b/w"
  array(5) {
    [0]=>string(1) "1"
    [1]=>string(1) "2"
    [2]=>string(1) "3"
    [3]=>string(1) "4"
    [4]=>string(1) "5"
  ["submit"]=>string(5) "Order"

looking at the dumped array, we can see that the drink and drinkno are paired by index that's all we need to know.

We change the code above to test if we can get pair.


    echo $_POST['drink'][0] .'=>'. $_POST['drinkno][0] .'<br/>';


You can also sort the not empty entries

$order ='';
$order .=(!empty($_POST[drink'][0] && !empty($_POST['drinkkno'][0] ?'drink type :'. $_POST[drink'][0].' quantity : '.$_POST['drinkkno'][0] : false );
$order .= '<br/>';

## do the same for the remaining drinks

Thanks guys Problem solved by complete re-write and change of db set up.
Now works as intended