How to search table information by id and send to another part on the same page?

Asked

Viewed 66 times

-2

I’m learning to program a short time and I’m creating my first system, which is a school bulletin system, where I have a tab called students that contains a table generated through a registration, each item of this table has an edit icon that redirects the user to a form where he records the respective student’s grade. I need that when the user clicks on the icon and it is redirected to the form the registered notes should be from the selected student. And the whole page is made with bootstrap

  • if possible put your Cod, print screens and or even bank modeling

  • Hello Pedro. You need to study a bit about HTTP methods like GET and POST. In your case specifically you could use GET to send the student code to another page. In your edit icon should contain a link that goes to the notes view page and in the link include the student code that you want to view. Already on the notes page you capture this value to search with it in your database.

1 answer

0


Try to create this icon of the item as link, and the link puts to call the specific page and assigns a parameter as for example

<a href="editar-alunos.php?id=1">Editar</a>

in php you make the query coming from the parameter:

$id = $_GET['id']; //Recebe o parâmetro passado pela sua url

and make the query in the database

$alunos = ("SELECT * FROM alunos WHERE id = '$id'");

Create a form with the fields where you will inform the student’s values for possible change for example:

<input type="text" name="nome" value="<?php echo $row['nome'] ?>"> //em Value você imprime a informação do aluno de acordo com a sua necessidade.

then just apply the amending action.

  • This same follows this example that goes right.

  • I actually need the icon to redirect to the form where I record the notes:

  • makes a page call by this icon example: <a href="page-do-form.php? id=student-id">Icone-aqui</a> on the.php form page creates a variable to receive the parameter via get for example: $id = $_GET['id']; which was the parameter passed by the id id=student-id. in the variable that receives the value you can use in your form for possible changes. In case of doubt publish your code so I can help you.

  • I got it here, it worked. Obg!

Browser other questions tagged

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