TCPDF - GET ID

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
dgniewek
Posts: 3
Joined: 2022-07-22 07:32

TCPDF - GET ID

Post by dgniewek » 2023-01-24 22:36

Hello !
I'm really desperate now and I don't know what to do.
I am trying to implement a PDF generation function in my project - using the TCPDF library.
I can't get ID to copy the variables to my PDF from the table data.
Do you know how I can get the ID from "dv"?

Here I am posting the current code to get the ID - which is not working
Thanks for any advice!

Code: Select all

 
 // Include the main TCPDF library (search for installation path).
require_once '/www/login/vendor/tecnickcom/tcpdf/tcpdf.php';

//1) Připojení k databázi
$mysqli = new mysqli("localhost", "username", "pass", "db");

//3) Načtení ID z POST nebo GET metody
$pk = $_POST['id'] ?? $_GET['id'] ?? $data['selectedID'];

//4) Načtení proměnných z aktuálního záznamu
$query = "SELECT * FROM objednavky WHERE id = '$pk'";
$result = $mysqli->query($query);
$row = $result->fetch_assoc();
$firma = $row['firma'];
$kontaktni_osoba = $row['kontaktni_osoba'];
$email = $row['email'];
$platce_ico = $row['platce_ico'];
$email = $row['cena_hod'];
 

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: TCPDF - GET ID

Post by jsetzer » 2023-01-25 06:05

What is the current value of $pk?

When executing your script from DV, are you passing id as parameter?

How do you call the script?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

dgniewek
Posts: 3
Joined: 2022-07-22 07:32

Re: TCPDF - GET ID

Post by dgniewek » 2023-01-25 14:40

Sorry, I posted the wrong code with the $pk value.
I'm trying to get the ID of the record to generate the variables just like this:

Code: Select all

//3) Načtení ID z POST nebo GET metody
$id = $_GET['id'];

//4) Načtení proměnných z aktuálního záznamu
$query = "SELECT * FROM objednavky WHERE id = '$id'";
$result = $mysqli->query($query);
$row = $result->fetch_assoc();
$firma = $row['firma'];
$kontaktni_osoba = $row['kontaktni_osoba'];
$email = $row['email'];
$platce_ico = $row['platce_ico'];
$email = $row['cena_hod'];
The scenario is that the user clicks on the "Download PDF" button in the appgini "DV" web application and the script would then retrieve the data from the database based on the ID that was passed as a parameter and create a PDF with that data.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: TCPDF - GET ID

Post by jsetzer » 2023-01-25 15:27

So, if you already have managed...

1. To create the button in DV,
2. on click, open your script and pass selectedID as id parameter in URL
3. and to get the correct ID from $_GET into $id variable

...then what is the problem?

If you need to get the record's primary key (PL) in DV you can use Javascript and get .val() from <input name="SelectedID" ...>
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
D Oliveira
AppGini Super Hero
AppGini Super Hero
Posts: 347
Joined: 2018-03-04 09:30
Location: David

Re: TCPDF - GET ID

Post by D Oliveira » 2023-01-25 22:36

you shouldn't be executing a query with this get request parameter without the makeSafe() function shielding from a mysql injection.

Post Reply