This topic is locked

Put a button on the record listing page that changes the value of a field in all records

4/27/2024 6:20:42 AM
PHPRunner General questions
A
alfonso authorDevClub member

I want to put a button at the top of a table list and when clicked I want it to update the field "hoy" of all the records that that table has. I know how to do it with MySQL but I don't know how to do it in PHPRunner

UPDATE nombre_de_tabla
SET hoy = 0;

Sergey Kornilov admin 4/27/2024

You can use Database API for this purpose:
https://xlinesoft.com/phprunner/docs/db_exec.htm

A
alfonso authorDevClub member 4/28/2024

I have to put this code: DB::Exec("UPDATE inventario SET hoy = 0;");
but I don't know where in custom button: Client before, Server or Client After

A
alfonso authorDevClub member 4/28/2024

I think it is correct in Server. I think it does it correctly, but then I get an "undefined!!!" message. below the button. And I would like to reload the listing page so that the changes can be seen

A
alfonso authorDevClub member 4/28/2024

Solved. I put in Client After:
var message = " - COMPLETE!";
ajax.setMessage(message);
location.reload();
Then refresh page. Message not showing. I also try with swal:
swal ( "Success", "Your data was updated!" , "success" );
location.reload();