How to print the selected database ID? [closed]

2

Is there a function to get information from a specific ID of my database and print with domf?

My code:

$id = "30";
$result_usuario = "SELECT * FROM cadastro WHERE id = '$id' LIMIT 1";
$resultado_usuario = mysqli_query($conn, $result_usuario);  
$row_usuario = mysqli_fetch_assoc($resultado_usuario);  

To display the information I need to place the id in $id = "30"; manually. Is there any way that when I'm on the page with the information I need to print it it automatically changes that id from the page I am on?

    
asked by anonymous 03.11.2017 / 15:39

1 answer

1

You can send the ID value through a GET or POST.

id = $_GET["id"];
$result_usuario = "SELECT * FROM cadastro WHERE id = '$id' LIMIT 1";
$resultado_usuario = mysqli_query($conn, $result_usuario);  
$row_usuario = mysqli_fetch_assoc($resultado_usuario);

and the id value varies according to GET: link.com/page?id=value

    
03.11.2017 / 16:07