1
I have an immovable site that I am implementing the option of favorites. When opening the property and clicking favorite, it should insert in a new row in the favorite table, this one below (status 1 is favorite), and if "decrypt" it removes the line:
id|idusuario|imovel|status
1 | 789 | 552 | 1
My question is how to do this dynamically, Realaltime. I have the variables $idusuario and $idimovel.
PHP code to insert or remove from bookmarks, just do not know how to call dynamically, without opening another page:
$query = ("INSERT INTO favoritos (idusuario, imovel, status)
VALUES ('".$idusuario."', '".$idimovel."', '1'");
$db->setQuery($query);
$db->execute();
Using
$.ajax()
, can it be? If you can put an example– Wees Smith
I don’t understand exactly where the difficulty is. Can you send the data to the server? Already have the connection to the database? The problem is building INSERT SQL code or more than that?
– bfavaretto
@Weessmith can yes, I do not have much knowledge in ajax
– Leandro Marzullo
@bfavaretto do not know how to do it right, I know it can be with ajax, but I do not know how to use well the ajax, the ones I did went wrong, only know if type click and open another page to rotate the instruction to insert a new line
– Leandro Marzullo
What exactly is
desclicar
?– user60252
@Leocaracciolo would be a click to reverse an action already done by another click
– Wees Smith
If it were a
input type="checkbox
or twoinput type="radio"
I think it would be better than a button that could confuse whether it was clicked or decrypted.– user60252
checkbox
tagged > status=1 unchecked > status = 0. Withradio
one for status 1 and the other for status 0– user60252
@Leandromarzullo vc already has php that makes these changes?
– Wees Smith
But there is also the possibility to change the button label
– user60252
Are just ideas for friend Wees Smith to consider in the promised response
– user60252
@Weessmith I have php, I think what Leo Cracciolo is a good, a checkbox, I edited the response with php I have created
– Leandro Marzullo
When removing the bookmark, delete the line or change the status?
– Wees Smith
is to delete the line, right? $query=("DELETE FROM favorites WHERE idusuario = ". $idusuario." AND imovel = ". $idimovel) ;
– Leandro Marzullo