views:

151

answers:

1

OK so let's say I have a textarea on the top of my browser and a text input box on the bottom. I want to connect a MySQL database and also whatever I type in the input box to appear in the text area. Sorta like a text RPG...

I know PHP, MySQL, good AJAX, and little jQuery. I just want to know how this is achieved. Thank you.

+1  A: 

You can do something like this (the code below sends input text to php script which connects to database, does whatever you want it to do and prints a text to be displayed in text area) :

$("#update_btn").click(function() {
    var txt = $.ajax({
    url: 'your_file.php',
    async: true, // or false, depends on your needs
    type:'POST',
    data:({new_text:$('#input_box_1').val()})
     }).responseText;

     $('#txt_area_1').val(txt);
    });

To access new_text variable in php script, use $new_text = $_POST["new_text"]

a1ex07