How can i send data from javascript to php and use him in MySQL query?

i'm trying to show some data from my sql database in some outputs. But to do that, i need to send a value from javascript to php, and it works, i do a echo and he show me the right value, the problem is, when i do my query SELECT * FROM utilizador WHERE idutilizador ='$id' he return 0 rows, but if i do SELECT * FROM utilizador WHERE idutilizador ='11' he shows me what i want. This is where i translate my value from javascript to php: $id = "<script>document.write(variavel_js)</script>"; and this is my php code to execute the query:

    $sql = "SELECT * FROM utilizador WHERE idutilizador ='$id'";
    $result = mysqli_query($conn,$sql) or die ("erro");  
    $row_usuario = mysqli_fetch_assoc($result); 

Can somebody help me?



from Recent Questions - Stack Overflow https://ift.tt/2M9KJON
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation