Update in mysql loop table

Asked

Viewed 284 times

-1

Hello, I have a mysql table that contains the student number and class date already registered, and I need to update the "GIFT" field with "S" or "N". In other words, register the traditional call. Could someone give me a suggestion? I am using PHP. I have a table that contains the student’s number, the date of the class. I have already solved this. Now I need to scan this table and go capturing for each line whether or not the student was present. I’m using a foreach but I’m not getting the "S" or "N" to update each line

  • What have you done in php? Only with this you can not know what is wrong in your code , post the code that is a complete, minimum and verifiable Example, if you do not know what is read here : https://answall.com/help/mcve

  • I don’t have the code yet. I’m looking for an orientation for a strategy to solve the problem. For example: if you use a foreach and inside the loop do such a thing, etc. It would not be necessary to elaborate the code, just indicate a strategy.

1 answer

1

UPDATE aluno SET presente = 'S' WHERE numero = ? AND data = ?

Or else:

UPDATE aluno SET presente = 'N' WHERE numero = ? AND data = ?

In the ? you enter the student’s number and date.

  • The problem is how to capture "S" or "N" before. There are 30 or 40 rows in the table. Each record can be updated with "S" or "N".

  • @Rui So your problem is not mounting SQL. Your problem is something else. Edit the question and tell us what your problem is, starting with the programming language you are using and the code you already have to make the call.

  • I am using PHP. I have a table that contains the student’s number, the date of the class. I have already solved this. Now I need to scan this table and go capturing for each line whether or not the student was present. I’m using a foreach but I’m not getting the "S" or "N" to update each line.

  • 1

    @Rui Then edit the question to make it clear to everyone, otherwise you won’t get much better answers than mine.

Browser other questions tagged

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