I have a real estate website that I'm implementing the favorites option. When you open the property and click favorite, it should insert a new row in the favorite table, the one below (status 1 is favorite), and if you "uncheck" it removes the row:
id|idusuario|imovel|status
1 | 789 | 552 | 1
My question is how to do this dynamically, realtime. I have the $ idusuario and $ idimovel variables.
PHP code to insert or remove from favorites, just do not know how to dynamically call, without opening another page:
$query = ("INSERT INTO favoritos (idusuario, imovel, status)
VALUES ('".$idusuario."', '".$idimovel."', '1'");
$db->setQuery($query);
$db->execute();