Welcome to WebmasterWorld Guest from 54.163.168.15

Forum Moderators: coopster & jatar k

Populating DB table with FORM data (loop)

   
4:16 pm on Aug 20, 2012 (gmt 0)



I am building a FORM from DB table "PriceList" that contain information about equipement that you can reserve. I need to save the form submission to a different table "quote_request" where each form line can be save as a record on "quote_request" table.

I have tried many things and I am still missing something. My code is not looping based on the number of line from the form and it is saving only the fisrt line.


I have tried the FOREACH, FOR and while, but I am still missing something.





Query to build the form:

mysql_select_db($database_PriceList, $PriceList);
$query_LOCA_SIT = "SELECT * FROM pricelist WHERE EQI_Code = 'SIT' and EQI_Code2 = 'LOCA' ORDER BY EQI_ID";
$LOCA_SIT = mysql_query($query_LOCA_SIT, $PriceList) or die(mysql_error());
$row_LOCA_SIT = mysql_fetch_assoc($LOCA_SIT);
$totalRows_LOCA_SIT = mysql_num_rows($LOCA_SIT);

FORM:
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<!--- TEMPORAIRES --->
<input name="COSTUMER_ID" type="text" id="COSTUMER_ID" value="yves.langlais@me.com" />
<br />
<input name="REQUEST_ID" type="text" id="REQUEST_ID" value="20120816142002" />
<br />
<!-- SALLES --->

SALLES <br />
<?php do { ?>
<input name="Select" type="checkbox" id="Salle1" value="1" checked="checked" />
<label for="EQI_ID"></label>
<input name="EQI_ID" type="text" id="EQI_ID" value="<?php echo $row_LOCA_SPA['EQI_ID']; ?>" size="5" maxlength="5" />
<label for="EQI_Qte"></label>
<input name="EQI_Qte" type="text" id="EQI_Qte" value="1" size="5" maxlength="5" />
<label for="LOCA_SPA"></label>
<?php echo $row_LOCA_SPA['EQI_Fr']; ?>
<label for="LOCA_SPA_PRICE"></label>
<input name="EQI_Price" type="text" id="LOCA_SPA_PRICE" value="<?php echo $row_LOCA_SPA['EQI_UP']; ?>" size="10" maxlength="10" />
$<br />

<?php } while ($row_LOCA_SPA = mysql_fetch_assoc($LOCA_SPA)); ?>
<br />


<!-- AUDIO --->
<input type="submit" name="button" id="button" value="Submit" />
<br />
<input type="hidden" name="MM_insert" value="form1" />
</form>
10:15 pm on Aug 20, 2012 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



a do/while is always going to execute once before checking the condition. So it's executing and then checking the condition and failing.

I see the while calls mysql_fetch_assoc($LOCA_SPA) but nowhere do I see $LOCA_SPA defined. So unless there's more to your script that you don't have here, it's going to evaluate to false and exit your loop after one round.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month