Advertisement

02.02.2008 at 06:19PM PST, ID: 23132686
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

PHP MySQL Insert multiple records - do I need a loop?

I am trying to insert multiple records into a MySQL database. The problem im having is that when i hit submit, only the values from the last row are being entered into the db.  The variable is QTY, for quantity.

Here is an example of a row from the HTML.  I have about 10 of these, that I want to enter different quantities into the DB when I hit submit:

          <td><div align="center" class="main-12px-verdana">Da'NOLLIE</div></td>
          <td><div align="center" class="main-12px-verdana">160cm</div></td>
          <td><div align="center" class="main-12px-verdana">4501<input id="SKU" name="SKU" type="hidden" value="4501">
          </div></td>

I know I need to loop through the values but im not quite sure how to do it.

I think that I need a loop to do this.  I'm using a helper program called Data Assist (www.webassist.com) to insert the records.  Here is the code I am trying to figure out how to add a loop to:

Any guidance on this would be much appreciated.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
<?php require_once('../Connections/icelanticordering.php'); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php 
// WA Application Builder Insert
if (isset($_POST["Insert"])) // Trigger
{
  $WA_connection = $icelanticordering;
  $WA_table = "Orders";
  $WA_sessionName = "WADA_Insert_Orders";
  $WA_redirectURL = "3uswholesale200809.php";
  $WA_keepQueryString = false;
  $WA_indexField = "OrderID";
  $WA_fieldNamesStr = "CustomerID|SKU|QTY";
  $WA_fieldValuesStr = "".((isset($_POST["CustomerID"]))?$_POST["CustomerID"]:"")  ."" . "|" . "".((isset($_POST["SKU"]))?$_POST["SKU"]:"")  ."" . "|" . "".((isset($_POST["QTY"]))?$_POST["QTY"]:"")  ."";
  $WA_columnTypesStr = "',none,''|',none,''|',none,''";
  $WA_fieldNames = explode("|", $WA_fieldNamesStr);
  $WA_fieldValues = explode("|", $WA_fieldValuesStr);
  $WA_columns = explode("|", $WA_columnTypesStr);
  $WA_connectionDB = $database_icelanticordering;
  mysql_select_db($WA_connectionDB, $WA_connection);
  if (!session_id()) session_start();
  $insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
  $WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
  $MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
  $_SESSION[$WA_sessionName] = mysql_insert_id();
  if ($WA_redirectURL != "")  {
    if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
      $WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
    }
    header("Location: ".$WA_redirectURL);
  }
}
?>
Start your free trial to view this solution
Question Stats
Zone: Web Development
Question Asked By: pankis
Solution Provided By: dr_dedo
Participating Experts: 1
Solution Grade: A
Views: 68
Translate:
Loading Advertisement...
02.02.2008 at 06:22PM PST, ID: 20807106

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.02.2008 at 07:11PM PST, ID: 20807323

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.02.2008 at 07:26PM PST, ID: 20807390

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.03.2008 at 06:19AM PST, ID: 20808710

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628