Good day!
I have a question. There are 3 tables in the database: user , items and useritems . I need to make a query to the user table and find out if there is such a user in the database, if there is, then output his ИМЯ and all the items that he has, and if there is no user with such a NAME, then we simply output a message that the user is added to database and automatically add an item to it.
In the useritems table I have 3 fields id , uid , and itmid and now I cannot figure out how to add a user there and assign him any item from the items table. Since when I click on the "add" button, only the user is added to the user table.
INSERT INTO `user` (`uname`) VALUES ('$nambreUsuario'); But how to add an item and a user in the useritems table, I will not useritems my mind. And at the same time, it should be that in the user table and the useritems table the user is under the same id
Script output information about the user.
$(document).ready(function () { $("#resultados").hide(); $('#buscar_usuario').autocomplete({ 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); }); $('#resultados').slideDown('slow'); } }); }); The script output information that the user added:
$(document).ready(function(){ $('#result').click(function(){ $.post("ajax.php",{"buscar_usuario":$("#buscar_usuario").val()}, $("#resultados").slideToggle("slow"), $(this).toggleClass("active") ) });