I am still relatively new to all the intricacies of PHP and am having a problem.

I have 10 different students (S1-S10) from the same school who all are given the same foods for lunch on a particular date.

They each get the same entree, condiment (like ketchup), grain, fruit, veggie1, veggie2, beverage1 and beverage2.

I need to be able to enter the amount of each item consumed (like 8 tater tots for the grain) and proportion consumed (i.e. None, 25%, 50%, 100%, other, etc.) for each student. The proportion consumed can be a drop down but it needs to allow you to type in a value if over 200%.

This data then needs to go into an Access table with each student (S1-S10) as a separate row.

Here are my Access fields in order:
schoolid (number) 1001=Burlington, 1002=CCC, 1003=Maple Woods
date (date/time)
student (number) S1=1, S2=2, S3=3 and so on
veg1 (text)
veg1amtconsumed (text)
veg1proportion (text)
veg2 (text)
veg2amtconsumed (text)
veg2proportion (text)
entree (text)
entreeamtconsumed (text)
entreeproportion (text)
condiment (text)
condimentamtconsumed (text)
condimentproportion (text)
bev1 (text)
bev1amtconsumed (text)
bev1proportion (text)
bev2 (text)
bev2amtconsumed (text)
bev2proportion (text)
grain (text)
grainamtconsumed (text)
grainproportion (text)
fruit (text)
fruitamtconsumed (text)
fruitproportion (text)

I haven't found any way to do this other than making people enter S1's information individually on the page, then go back and enter S2's and repeat the back and forth process for all 10 students, which is a pain. Can anyone help me out with this?

    This doesn't give an error code, but it doesn't go into the database either. I know that the odbc call is correct. I have the html form and the php insert on different pages.

    the form:

    <form name="lunch" action="lunch_add_multiple.php" method="post">
    <script type="text/javascript" language="JavaScript"><!-- --></script>
    <title>Lunch Consumption Form</title>
    
      <b><u>Lunch Consumption Monitoring Form</u></b>
      <table width="88%" border="0">
        <tr>
          <td nowrap bordercolor="#000000"><div align="center" class="style1">
              <p align="justify" class="style8"></p>
    
          <p align="justify"><strong>School: </strong>
            <select name="schoolid">
                <option value="1001">Burlington</option>
                <option value="1002">CCC</option>
                <option value="1003">Maple Woods</option>
            </select>
          </strong>
          &nbsp;&nbsp;&nbsp;&nbsp;<strong>Date:</strong>
            <input name="date" type="text" id="date" size="10" maxlength="8">
          </p>
          <p align="justify"><strong>Entree: </strong>
            <input name="entree" type="text" id="entree" size="40" maxlength="50">
            <strong>Condiment:</strong>
            <input name="condiment" type="text" id="condiment" size="40" maxlength="50">
          </p>
          <p align="justify"><strong>Grain: </strong>
            <input name="grain" type="text" id="grain" size="40" maxlength="50">
            <strong>Fruit:</strong>
            <input name="fruit" type="text" id="fruit" size="40" maxlength="50">
          </p>
          <p align="justify"><strong>Vegetable 1: </strong>
            <input name="veg1" type="text" id="veg1" size="40" maxlength="50">
           <strong>Vegetable 2:</strong>
            <input name="veg2" type="text" id="veg2" size="40" maxlength="50">
          </p>
          <p align="justify"><strong>Beverage 1: </strong>
            <input name="bev1" type="text" id="bev1" size="40" maxlength="50">
            <strong>Beverage 2:</strong>
            <input name="bev2" type="text" id="bev2" size="40" maxlength="50">
          </p>
          <br>
          <table width="100%">
        	<tr>
        		<td width="10%"><b>Student</b></td>
        		<td width="20%">&nbsp;</td>
        		<td width="45%"><b>Amount Consumed</b></td>
        		<td width="35%"><b>Proportion Consumed (in %)</b></td>
        	</tr>
        	<tr>
          		<td align="left">
          		<select name='student[]' size='10' multiple>
                <option value='1'>S1</option>
                <option value='2'>S2</option>
                <option value='3'>S3</option>
                <option value='4'>S4</option>
                <option value='5'>S5</option>
                <option value='6'>S6</option>
                <option value='7'>S7</option>
                <option value='8'>S8</option>
                <option value='9'>S9</option>
                <option value='1-'>S10</option>
            </select>
            	<td align="left">Entree</td>
            	<td><input name="entreeamtconsumed" type="text" id="entreeamtconsumed" size="40" maxlength="50"></td>
            	<td><input name="entreeproportion" type="text" id="entreeproportion" size="2" maxlength="3"></td>
            </tr>
            <tr>
          		<td>&nbsp;</td>
            	<td align="left">Fruit</td>
            	<td><input name="fruitamtconsumed" type="text" id="fruitamtconsumed" size="40" maxlength="50"></td>
            	<td><input name="fruitproportion" type="text" id="fruitproportion" size="2" maxlength="3"></td>
            </tr>
            <tr>
          		<td>&nbsp;</td>
            	<td align="left">Vegetable 1</td>
            	<td><input name="veg1amtconsumed" type="text" id="veg1amtconsumed" size="40" maxlength="50"></td>
            	<td><input name="veg1proportion" type="text" id="veg1proportion" size="2" maxlength="3"></td>
            </tr>
            <tr>
          		<td>&nbsp;</td>
            	<td align="left">Vegetable 2</td>
            	<td><input name="veg2amtconsumed" type="text" id="veg2amtconsumed" size="40" maxlength="50"></td>
            	<td><input name="veg2proportion" type="text" id="veg2proportion" size="2" maxlength="3"></td>
            </tr>
            <tr>
          		<td>&nbsp;</td>
            	<td align="left">Grain</td>
            	<td><input name="grainamtconsumed" type="text" id="grainamtconsumed" size="40" maxlength="50"></td>
            	<td><input name="grainproportion" type="text" id="grainproportion" size="2" maxlength="3"></td>
            </tr>
            <tr>
          		<td>&nbsp;</td>
            	<td align="left">Condiment</td>
            	<td><input name="condimentamtconsumed" type="text" id="condimentamtconsumed" size="40" maxlength="50"></td>
            	<td><input name="condimentproportion" type="text" id="condimentproportion" size="2" maxlength="3"></td>
            </tr>
            <tr>
          		<td>&nbsp;</td>
            	<td align="left">Beverage 1</td>
            	<td><input name="bev1amtconsumed" type="text" id="bev1amtconsumed" size="40" maxlength="50"></td>
            	<td><input name="bev1proportion" type="text" id="bev1proportion" size="2" maxlength="3"></td>
            </tr>
            <tr>
          		<td>&nbsp;</td>
            	<td align="left">Beverage 2</td>
            	<td><input name="bev2amtconsumed" type="text" id="bev2amtconsumed" size="40" maxlength="50"></td>
            	<td><input name="bev2proportion" type="text" id="bev2proportion" size="2" maxlength="3"></td>
            </tr>
          </table>
    	  <!--<p align="justify">&nbsp;</p>
          <p align="right">ENTER
            <input name="enter" type="text" id="enter" size="10" maxlength="5">
          </p>
          <p align="right">REVIEWED
            <input name="reviewed" type="text" id="reviewed" size="10" maxlength="5">
          </p>-->
          <p align="justify">
            <input type = "hidden" name = "action_h" value = "save">
    		<input type = "hidden" name = "user_id" value = "<?php echo $user_id ?>">
    
            <input name="submit" type = "submit" class="style13" value="SUBMIT">
    	  </p>
          <p align="justify">&nbsp;</p>
      </div>
      </td>
    </tr>
      </table>
      <p>&nbsp;</p>
    </form>

    And the lunch_add_multiple.php

    <?php
    echo '<br><table><tr><td><b>';
    foreach ($HTTP_POST_VARS as $key => $value) {
    $temp = stripslashes($value);
    $HTTP_POST_VARS[$key] = $temp;
    }
    echo '</td></tr></table></b>';
    
    $schoolid=isset($HTTP_POST_VARS['schoolid']) ? $HTTP_POST_VARS['schoolid'] :'NA';
    $date=isset($HTTP_POST_VARS['date']) ? $HTTP_POST_VARS['date'] :'00/00/0000';
    //$student=isset($HTTP_POST_VARS['student']) ? $HTTP_POST_VARS['student'] :'NA';
    $veg1=isset($HTTP_POST_VARS['veg1']) ? $HTTP_POST_VARS['veg1'] : 0;
    $veg1amtconsumed=isset($HTTP_POST_VARS['veg1amtconsumed']) ? $HTTP_POST_VARS['veg1amtconsumed'] : 0;
    $veg1proportion=isset($HTTP_POST_VARS['veg1proportion']) ? $HTTP_POST_VARS['veg1proportion'] : 0;
    $veg2=isset($HTTP_POST_VARS['veg2']) ? $HTTP_POST_VARS['veg2'] : 0;
    $veg2amtconsumed=isset($HTTP_POST_VARS['veg2amtconsumed']) ? $HTTP_POST_VARS['veg2amtconsumed'] : 0;
    $veg2proportion=isset($HTTP_POST_VARS['veg2proportion']) ? $HTTP_POST_VARS['veg2proportion'] : 0;
    $entree=isset($HTTP_POST_VARS['entree']) ? $HTTP_POST_VARS['entree'] : 0;
    $entreeamtconsumed=isset($HTTP_POST_VARS['entreeamtconsumed']) ? $HTTP_POST_VARS['entreeamtconsumed'] : 0;
    $entreeproportion=isset($HTTP_POST_VARS['entreeproportion']) ? $HTTP_POST_VARS['entreeproportion'] : 0;
    $condiment=isset($HTTP_POST_VARS['condiment']) ? $HTTP_POST_VARS['condiment'] : 0;
    $condimentamtconsumed=isset($HTTP_POST_VARS['condimentamtconsumed']) ? $HTTP_POST_VARS['condimentamtconsumed'] : 0;
    $condimentproportion=isset($HTTP_POST_VARS['condimentproportion']) ? $HTTP_POST_VARS['condimentproportion'] : 0;
    $bev1=isset($HTTP_POST_VARS['bev1']) ? $HTTP_POST_VARS['bev1'] : 0;
    $bev1amtconsumed=isset($HTTP_POST_VARS['bev1amtconsumed']) ? $HTTP_POST_VARS['bev1amtconsumed'] : 0;
    $bev1proportion=isset($HTTP_POST_VARS['bev1proportion']) ? $HTTP_POST_VARS['bev1proportion'] : 'NA';
    $bev2=isset($HTTP_POST_VARS['bev2']) ? $HTTP_POST_VARS['bev2'] : 0;
    $bev2amtconsumed=isset($HTTP_POST_VARS['bev2amtconsumed']) ? $HTTP_POST_VARS['bev2amtconsumed'] : 0;
    $bev2proportion=isset($HTTP_POST_VARS['bev2proportion']) ? $HTTP_POST_VARS['bev2proportion'] : 'NA';
    $grain=isset($HTTP_POST_VARS['grain']) ? $HTTP_POST_VARS['grain'] : 0;
    $grainamtconsumed=isset($HTTP_POST_VARS['grainamtconsumed']) ? $HTTP_POST_VARS['grainamtconsumed'] : 0;
    $grainproportion=isset($HTTP_POST_VARS['grainproportion']) ? $HTTP_POST_VARS['grainproportion'] : 'NA';
    $fruit=isset($HTTP_POST_VARS['fruit']) ? $HTTP_POST_VARS['fruit'] : 0;
    $fruitamtconsumed=isset($HTTP_POST_VARS['fruitamtconsumed']) ? $HTTP_POST_VARS['fruitamtconsumed'] : 'NA';
    $fruitproportion=isset($HTTP_POST_VARS['fruitproportion']) ? $HTTP_POST_VARS['fruitproportion'] : 'NA';
    
    $conn = odbc_connect("YKIDS","","");
    
    if (isset($_POST['student'])) {
    	foreach ($_POST['student'] as $student) {
    $insert_statement = "
    	insert into 
    		lunch_consumption 
    		values ($schoolid, '$date', $student, '$veg1', '$veg1amtconsumed', '$veg1proportion', '$veg2', '$veg2amtconsumed', '$veg2proportion', '$entree', '$entreeamtconsumed', '$entreeproportion', '$condiment', '$condimentamtconsumed', '$condimentproportion', '$bev1', '$bev1amtconsumed', '$bev1proportion', '$bev2', '$bev2amtconsumed', '$bev2proportion', '$grain', '$grainamtconsumed', '$grainproportion', '$fruit', '$fruitamtconsumed', '$fruitproportion')";
    
    //echo $insert_statement;
    //if($error_rep==0)
    //{
    $result = odbc_exec($conn,$insert_statement);
    if(!$result) echo odbc_errormsg();
    }
    }
    ?>
    
      Write a Reply...