Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:53:56+00:00 2026-06-11T18:53:56+00:00

I have a form, whose fields can be increased by click on ‘[+]’ sign.

  • 0

I have a form, whose fields can be increased by click on ‘[+]’ sign.

the code that I use for the form is

Description
Quantity
Price
‘;

// Loop to prepare the display of 100 product lines
for ($i=0; $i<100; $i++) {

   if ($text['quantity'][$i] == "") $text['quantity'][$i] = 1;
   if ($text['unit'][$i] == "") $text['unit'][$i] = "0.00";
   // Display only the first line
   if ($nbr_ligne == 0) $nbr_ligne = 1;
   if ($i >= $nbr_ligne) $display = 'style="display:none"';
   echo '
   <tr id="cell'.$i.'" '.$display.'>
       <td>
           <textarea name="text[detail]['.$i.']">'.stripslashes($text['detail'][$i]).'</textarea>
           <br />
           <a href="javascript:void(0)" onclick="javascript:document.getElementById(\'cell'.($i+1).'\').style.display=\'table-row\'; this.style.display=\'none\'">[+]</a>
       </td>
       <td>
           <input name="text[quantity]['.$i.']" id="q'.$i.'" value="'.stripslashes($text['quantity'][$i]).'" size="4" />
       </td>
       <td>
           <input name="text[unit]['.$i.']" id="u'.$i.'" value="'.stripslashes($text['unit'][$i]).'" size="7" /> USD
       </td>
   </tr>';
}

echo '
   </table>
   <input type="submit" name="save" value="Save" />
</form>
';
if(isset($_POST['save']))
{
    echo $text['quantity']['.$i.'];

       mysql_connect("localhost","root","");
       mysql_select_db("rvt") or die("unable to select db");
       extract($_POST);
       $insert=mysql_query("insert into add(description, quantity, price) values('$text[detail][".$i."]','$text[quantity][".$i."]','$text[unit][".$i."]')");
    if($insert)
    {
        echo "hi";
    }
}
?>

I want to store the data to database. It not works.

Plz help me in storing data in database.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:53:57+00:00Added an answer on June 11, 2026 at 6:53 pm

    Your query will not work due to a PHP parser “bug”. It is not a greedy parser, so something like:

    echo "$array[1][2]";
    

    will actually produce as output

    Array[2]   <---yes, the literal word 'Array'.
    

    and not whatever value is stored at index 2 of the sub-array at index 1.

    because PHP’s parser stops considering array references after the first set of []. You need to use {} notation:

    ... values('{$text['detail'][$i]}', etc...
                ^                   ^
    

    note the position of the {}, and the additional ' around the detail key.

    As well, please do not use extract(), especially on _GET/_POST. You’re essentially reproducing the very horribly nastily ugly bad days of when register_globals was turned on in PHP. It’s a security hole just waiting to get exploited.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that contains dataGridView, whose coloumn are set to dgrv1.Width =dgrv1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible)+20;
Let's say I have a form where users can search for people whose name
I have form, where some fields are looks like rows, so I can add/delete
From the source code, you can see that Django 1.4's Form class has a
I have some asp.net code that populates the fields in a LINQ to SQL
I have an input form that has 38 fields I know it's too much
I have a form containing name,email,message and captcha fields. I can submit the form
I have a form builder app where i can click to add a new
I have a form which contains a whole heap of data entry fields that
I have two hidden input fields on my form that I have linked to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.