Jump to content

Inserting with a repeat region form


cdoggg94

Recommended Posts

So this is the code for my form.  It is a table that shows all records in a table on my database.

 

my plan is to have an add button at the right most column so they can add a number into the Qty text box and press add.  When you press add i want it to insert as a new entry in my db with the information below.

 

<div id="newListForm">
<?php
$mydate = getDate();
$thismonth = $mydate['month'];
$thisday = $mydate['mday'];
$thisyear = $mydate['year'];
$thisTime = date('H:i:s');
$mymessage = $thismonth." ".$thisday.", ".$thisyear;
?>
<form action="<?php echo $editFormAction; ?>" id="form" name="form" method="POST">
<table border="0">
    	<tr align="center">
        	<th width="60" align="left">LCBO #</th>
            <th width="250" align="left">Product</th>
            <th width="40">Size</th>
            <th width="50">Btl/cs</th>
            <th width="54">LTO</th>
            <th width="79">Price</th>
            <th width="103">Qty</th>
            <th width="91">
            
            
            </th>
        </tr>
        <?php do { ?>
  <tr>

    <td><?php echo $row_AllWine['lcbo_num'] ;?></td>
    <td><?php echo $row_AllWine['pro_name'] ;?></td>
    <td align="center"><?php echo $row_AllWine['pro_size'] ;?></td>
    <td align="center"><?php echo $row_AllWine['pro_btl'] ;?></td>
    <td align="center">
    <span class="LTOlist">
    	<?php
		if($row_AllWine['F7']=="LTO"){
			echo "LTO";
		}else{
			echo "";
		}
	?>
    </span>
    </td>
    <td align="center"><?php echo $row_AllWine['pro_price'] ;?></td>
    <td align="center"><input name="qty" type="text" size="10" /></td>
    <td align="right">
     <input type="hidden" name="date" id="date" value="<?php echo $mymessage ;?>" />
  <input type="hidden" name="product" id="product" value="<?php echo $row_AllWine['pro_name'] ;?>" />
  <input type="hidden" name="client" id="client" value="<?php echo $detnum ;?>" />
  <input type="hidden" name="id" id="id" value="" />
  <input type="hidden" name="normal" id="normal" value="<?php echo $row_AllWine['pro_price'] ;?>" />
  <input type="hidden" name="normalCase" id="normalCase" value="<?php echo "" ;?>" />
  <input type="hidden" name="LTO" id="LTO" value="<?php echo "" ;?>" />
  <input type="hidden" name="LTOCase" id="LTOCase" value="<?php echo "" ;?>" />
    <input name="submit" type="submit" value="Add" /></td>
  </tr>
  <?php } while ($row_AllWine = mysql_fetch_assoc($AllWine)); ?>
    	<tr>
        	<td colspan="8" align="right"> </td>
        </tr>
    </table>
<input type="hidden" name="MM_insert" value="form" />
</form>
</div>

 

 

below here is the dream weaver created code for inserting that i am trying to use.

 

<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
  $insertSQL = sprintf("INSERT INTO wish_list (wish_id, wish_client, wish_product, wish_bottle, wish_case, wish_bottle_LTO, wish_caseLTO, wish_total, wish_date) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['id'], "int"),
                       GetSQLValueString($_POST['product'], "text"),
                       GetSQLValueString($_POST['client'], "text"),
                       GetSQLValueString($_POST['normal']*$_POST['qty'], "text"),
                       GetSQLValueString($_POST['normalCase'], "text"),
                       GetSQLValueString($_POST['LTO'], "text"),
                       GetSQLValueString($_POST['LTOCase'], "text"),
                       GetSQLValueString($_POST['normal']*$_POST['qty'], "text"),
                       GetSQLValueString($_POST['date'], "text"));

  mysql_select_db($database_myConnect, $myConnect);
  $Result1 = mysql_query($insertSQL, $myConnect) or die(mysql_error());

  $insertGoTo = "NewOrder.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>

 

basically i think that its not working because of how my form is set up...

 

when i echo out the values for the hidden fields it does show content.  it just doesnt want to insert them into the DB..

 

does anyone have any advice? or see something that I am obviously over looking ?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.