How to print the selected database ID?

Asked

Viewed 46 times

2

Is there a function to take 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 put the id on $id = "30"; manually. Is there any way when I’m on the page with the information I need to print it automatically changes that id by the page I’m on?

  • what does domf mean? see in your question e imprimir com o domf? I sincerely do not know this term. But anyway it would be interesting to post the full code

1 answer

1

You can send the ID value via 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.