Bit of everything really

I have a page with the following above the html tags

$insertSQL = sprintf(“INSERT INTO prices (price_id, price_head, price_amount, price_extra, property_id)
VALUES (’$prop_price_id’, ‘$headA_0’, ‘$headB_0’, ‘$headC_0’, ‘$curr_Property’)”);
mysql_select_db($database_connect, $connect);
$Result1 = mysql_query($insertSQL, $connect) or die(mysql_error());

then between the head tags I have

<script type="text/javascript">
var inputCount = 0;
function addLine() {
var objSource = window.event.srcElement;
var currentTR, currentTD, currentSelect, temp;

//set row number
//here we will delete the line 
 while ( (objSource = objSource.parentElement)  && objSource.tagName !="TBODY");
//add the tr to the table
 currentTR = objSource.insertRow();
 currentTD = currentTR.insertCell();
 currentTD.innerHTML = "<input type='text' size='30' name='headA_"+inputCount+"'>";
 currentTD = currentTR.insertCell();
 currentTD.innerHTML = "<input type='text' size='15' name='headB_"+inputCount+"'>";
 currentTD = currentTR.insertCell();
  currentTD.innerHTML = "<input type='text' size='15' name='headC_"+inputCount+"'>";
 currentTD = currentTR.insertCell();
 currentTD.innerHTML = "<input type='button' class='Button' onclick='addLine()' value='Insert'> <input type='Button' class='Button' onclick='removeLine()' value='Delete'>";

function removeLine() {
 var current = window.event.srcElement;
//here we will delete the line 
while ( (current = current.parentElement)  && current.tagName !="TR");

in the body I have



What is happening is the

  1. The SQL is not incrementing. Its overwriting the previous entry and incrementing the id.

  2. The java add a line to the table with 3 text boxes in the text box names are incremented. How do I add these the the database.

Hope someone can help because i’ve been pulling my hair out for 6 hours trying to get it working and am now bald. :wink:

Sorted it

Sponsor our Newsletter | Privacy Policy | Terms of Service