Jump to content

can't dump all the info


mariocesar

Recommended Posts

hi, I got this table is working fine but just the first row is upload in to my sql table, how can I feed the complete info all 11 rows at once, here is the code (table):

<form method="POST" action="dumpinfo.php" name="form" >
<table width="750" cellspacing="1" cellpadding="3" >
  <tr>
    <td><div align="center">productid</div></td>
    <td><div align="center">baseprice</div></td>
    <td><div align="center">quantity</div></td>
    <td><div align="center">5peroff</div></td>
    <td><div align="center">10peroff</div></td>
    <td><div align="center">15peroff</div></td>
    <td><div align="center">20peroff</div></td>
    <td><div align="center">25peroff</div></td>
    <td><div align="center">30peroff</div></td>
    
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr>
    <td><font color="#003366" > 

        <input name="productid" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="baseprice" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="quantity" type="text" size="12"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fiveperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="tenperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="fifperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="twfperoff" type="text" size="8"> 

        </font></td>
    <td><font color="#003366" > 

        <input name="thrperoff" type="text" size="8"> 

        </font></td>
   
  </tr>
  <tr><td colspan="9" align="center"><input type="submit" name="Submit2" value="Submit" onClick="return validate(form)">

<INPUT type="reset" value="Cancel"> </td></tr>
</table></form>

 

 

//and here is the php script:

 

<?php 

///////////////////////  CONNECT TO MYSQL DB  //////////////////// 

// OPEN CONNECTION ---> 

$connection=mysql_connect('securebut', $user = "productdetail", $pass = "loco07") or die("Unable to connect!"); /* change this! */ 

mysql_select_db("productdetail") or die("Unable to select database!"); /* change this! */ 

//  EXECUTE QUERY ---> 

$query="INSERT INTO productdetail ( productid, baseprice, quantity, 5peroff, 10peroff, 15peroff, 20peroff, 25peroff, 30peroff) 

        VALUES( '".$productid."', '".$baseprice."', '".$quantity."', '".$fiveperoff."', '".$tenperoff."', '".$fifperoff."', '".$twperoff."', '".$twfperoff."', '".$thrperoff."')"; 

//////-----> 
$result=mysql_query($query) or die("Error in query:".mysql_error()); 
if ($result) 
echo mysql_affected_rows()." Thanks, Mario a record was inserted into the database effectively, go back and insert the next one, You are the Best"; 
//  CLOSE CONNECTION ---> 

mysql_close($connection); 

?></td></table>

 

Thanks in advance.

Link to comment
Share on other sites

well with such coding you can't , but it is easy to solve.

put a "  [] "  next to each  name of an input .

 

 

like :

 

<input name="productid[]" type="text" size="8">

 

 

now when you click submit it will post an array to your script containing your values .

so all the 11 rows for the input with name  name="productid[]"  will be  in :

$_POST[productid] which can access by  :

 

$_POST[productid][0]  $_POST[productid][1]    $_POST[productid][2]    $_POST[productid][3]  till  [10] .

 

now that you have it , set a counter for each 11 in the script :

 

$i = 0
while ($i < 11)
     {

$query="INSERT INTO productdetail ( productid, baseprice, quantity, 5peroff, 10peroff, 15peroff, 20peroff, 25peroff, 30peroff) 

        VALUES( '".$_POST[productid][$i]."', '".$_POST[baseprice][$i]."', ... // do for all the values 

//////-----> 
$result=mysql_query($query) or die("Error in query:".mysql_error()); 
if ($result) 
echo mysql_affected_rows()." Thanks, Mario a record was inserted into the database effectively, go back and insert the next one, You are the Best"; 

$i++;

     }


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.