0

I need to insert input field data into MySQL. But the thing is that input field is vary.

take a look at my page http://www.chatfitness.com/add_malayalam.php

enter image description here

Jquery add input field code

$(document).ready(function() {
    var scntDiv = $('#add_words');
    var wordscount = 1 ;
    var i = $('.line').size() + 1; 
    $('#add').click(function() { 
        wordscount++;
//      $('<div class="line">Word is ' + wordscount + '<input type="text" class="input' + wordscount + '" value="' + wordscount + '" /><a class="remScnt">Remove</a></div>').appendTo(scntDiv); 
        $('<div id="em_in" class="line" style="display:none"><div class="word_label">English </div><input type="text" name="malayalam[]" class="input' + wordscount + ' hinput" /><a class="remScnt">Remove</a></div>').appendTo(scntDiv).slideDown();
        i++; 
        return false;
    });

form details

    <form method="post" action="">
    <div class="add_word"><div class="word_label">Malayalam</div><input type="text" name="english" class="hinput" /></div>
<div id="add_words">
    <div class="line"><div class="word_label">English</div><input name="malayalam[]" class="search_word input1 hinput" type="text" /></div>

</div>
    <div id="add_wordD">+ <a id="add">Add another word</a>
        <input type="submit" name="submit" value="submit" class="submit"  style="margin-left:30px;"/>
    </div>
    </form>

could you please give a solution for it please. thanks in advance

6
  • Please post the code you are using. Commented Feb 26, 2012 at 13:50
  • I don't understand your question! Commented Feb 26, 2012 at 13:50
  • So we are suppose to know the code from html! Great! Sorry, no book taught me that. Commented Feb 26, 2012 at 13:52
  • @Michael markus-tharkun itachi I have just changed the question format. sorry my language and also i am happy for your interest :) Commented Feb 26, 2012 at 13:56
  • I still don't understand. What's happening and what's you expect? This is the same code of your page link? Commented Feb 26, 2012 at 14:07

1 Answer 1

2

If you want to insert each translation to separate row, this is the way:

<?php

$eng = mysql_real_escape_string($_POST['english']);
foreach ($_POST['malayalam'] as $val) {
    $mal[] = mysql_real_escape_string($val);
    $query = sprintf("INSERT INTO table (english, mal) VALUES (%s, %s)",
        $eng,
        mysql_real_escape_string($mal);
    // execute query
}

Of course I don't know what database wrapper you use or what's the table layout.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.