usage of post date ($_POST) or variable ($nom)
usage of post date ($_POST) or variable ($nom)
Hi,
I'm not a specialist in program language but Data Tables help me a lot to build what I need.
Now i'm blocked on it:
<?php
// DataTables PHP library
include( "../../DataTables_new/Original/php/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
//mysqli_set_charset($db,'utf8');
//$db->sql( "SET NAMES 'utf8'" );
//$db->query("SET NAMES 'utf8'")->exec();
Editor::inst( $db,'prat_listing')
->fields(
Field::inst( 'ID' )->validator( 'Validate::notEmpty' ),
This is the part where I need help
)
->where( function ( $q ) {
$q->where( function ( $r ) {
$r->or_where( 'nom', $_POST['nom']);
// $r->or_where( 'nom', $nom);
} );
} )
->process( $_POST )
->json();
<?php
>
```
?>
I tried to create a form where user is providing it's name and following the name provided I must have a table with some information. concerning only this user.
Continuer
Problem I tried both:
$r->or_where( 'nom', $_POST['nom']);
$r->or_where( 'nom', $nom);
```
and nothing works. so I don't know how to write it correctly
many thanks in advance for your help
kind regards
Philippe
This discussion has been closed.
Answers
I guess the first question is, are you POSTing the
nom
value with the DataTables and Editor Ajax requests?ajax.data
andajax.data
can be used for that.Allan
Thanks allan for your answer.
No I just post my "nom" value via a form in html
To be honest I don't undrestand your question
But I do a additional test:
If In
I replace gestion_modification.php by script_modification.php
it works with:
But I don't have a table only the data is diplayed.
Modification.php is the file where I have the form and users can enter is name (nom)
gestion_modification.php is my file where all the settings is done to built the table.
script_modification.php is the file where I place my server request (DB request)
So my question is how can I used the post_data value from gestion_modification.php to script_modification.php.
I don't know if you understand, it is really complex for me to explain
I still blocked on this subjet, could I have some help / guidance, please
First file HMTL where fill in the formular:
the datatable file:
server side:
I'm blocked since along time now
Could please kindly help me
maybe just provide a concrete example
This is not a data tables related issue and I am afraid you can't expect any help on stuff like this in this forum. Sorry. But let me give it a try:
You need to understand the difference between a $_POST and a $_SESSION variable. Read the PHP docs please or take an online course. There are many of them.
Here is an example:
Upon log in I save the id of the user in a session variable that I use later on in Editor queries as well. This certainly would not work with a $_POST variable.
I call my login function and save a couple of session variables if login was successful
Upon logout the session variables are deleted:
I can use the session variables in Editor as well:
thanks a lot for your answer. Ok I think that I understand the variable "nom" is already used in the second file, so When I call it in the third page, it doesn't exist anymore.
so I may used $_SESSION to keep the variable in my entire process.
I will try it directly
thanks so much to have answe