How to implement such a function in jQuery?

Good afternoon!

I have a question. There are 3 tables in the database: id, itemsand id. I need to make a query to the idtable and find out if there is such a user in the database, if there is, then we display his and all the items that he has, and if the user does not exist with this NAME, then we simply display a message that the user has been added to the database and automatically add an item to him.

In the table idI have 3 fields id, uid, and itmidand now I can’t figure it out , how to add a user there and assign any item from the itemstable to him. Since when I click on the “add” button, only the user is added to the table id.

INSERT INTO `user` (`uname`) VALUES ('$nambreUsuario');

But I don’t know how to add an item and a user in the idtable. And at the same time, the user must be under the same id.

in both the idtable and the idtable.

Script to display user information.

$(document).ready(function () {
        source: 'ajax.php',
        select: function (event, ui) {
            $('#resultados').slideUp('slow', function () {
                $('#resultados').html('<h2>  <h2>' + '<img src="' + ui.item.foto + '"/>' + '<strong>: </strong>' + ui.item.value + '<br/>' + '<strong> :
    </strong>' + ui.item.descripcion);

Script to display information that the user has been added:


Answer 1, authority 100%

Something like this:

mysql_query("INSERT INTO ` ` SET ``='', ``='';");