homepage Welcome to WebmasterWorld Guest from 54.197.110.151
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Populating DB table with FORM data (loop)
Tommymtl



 
Msg#: 4486525 posted 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>

 

ergophobe

WebmasterWorld Administrator ergophobe us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4486525 posted 10:15 pm on Aug 20, 2012 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved