problem creating printable page

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

problem creating printable page

Post by fgazza » 2019-09-24 18:36

Hello to all,
I am desperate!
I'm trying to follow the example that Ahmed published during udemy "creating a printable invoice".

I have a table called "Partecipazione_evento_pubblico" with a primary key called "pri_key". I have created a "stampa attestato" (=print certificate) button in the dv of the table "partecipazione_evento_pubblico". The button links to the "attestato_evento_pubblico.php" file.

My goal is to create a custom page where some fields of the table "Partecipazione_evento_pubblico" are shown with a particular layout.

Following the tutorial in the udemy course I was hoping to be able to view, in the page https://sullabuonastrada.org/governance ... pri_key=66 (where 66 is the primary key of the record on which I clicked) the fields of the table "partecipazione_evento_pubo "with data of the recors with pri_key 66.
Unfortunately instead I get an error in the query and I just can't understand where I'm wrong!

In fact when I click on the button the page https://sullabuonastrada.org/governance ... pri_key=66 opens but the fields of the form with primary key 66 do not appear on the page and this error appears:
"Column 'pri_key' in where clause is ambiguous".

at link http://circolovega.org/files.rar you can download:

1) error message.docx (full description of error message with the whole query text)

2) the file attestato_evento_pubblico.php (the file that opens by clicking on "stampa attestato" (= print certificate) but showing the error.

3) the file partecipazione_evento_pubblico.php (which is located in the hooks folder and contains the customization of the table "partecipazione_evento_pubblicot").

I really hope someone can help me understand where I'm wrong! THANK YOU ALL!

Fabiano

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: problem creating printable page

Post by pbottcher » 2019-09-24 18:42

Hi Fabian,

try to replace

`pri_key`

with

`partecipazione_evento_pubblico`.`pri_key`

in your query (after the where)
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: problem creating printable page

Post by fgazza » 2019-09-24 19:17

Thank you pböttcher!

But my code to generate the query is:

<?php
$currDir = dirname(__FILE__);
include("$currDir/defaultLang.php");
include("$currDir/language.php");
include("$currDir/lib.php");
include_once("$currDir/header.php");


/* grant access to all users who have access to the partecipazione_evento_pubblico table */
$evento_from = get_sql_from('partecipazione_evento_pubblico');
if(!$evento_from) exit(error_message('Accesso Negato!', false));


/* grant access to all logged users
$mi = getMemberInfo();
if(!$mi['username'] || $mi['username'] == 'guest'){
echo "Access denied";
exit;
}

/* get evento */
$evento_id = intval($_REQUEST['pri_key']);
if(!$evento_id) exit(error_message('Identificativo Evento non valido!', false));

/* retrieve evento info */
$evento_fields = get_sql_fields('partecipazione_evento_pubblico');
$res = sql("select {$evento_fields} from {$evento_from} and pri_key={$evento_id}", $eo);
$evento = db_fetch_assoc($res);

var_dump($evento);

include_once("$currDir/footer.php");
?>

... so....

where i have to put `partecipazione_evento_pubblico`.`pri_key`?

Thank you!!!

Fabiano

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: problem creating printable page

Post by pbottcher » 2019-09-24 19:33

change

$res = sql("select {$evento_fields} from {$evento_from} and pri_key={$evento_id}", $eo);

to

$res = sql("select {$evento_fields} from {$evento_from} and partecipazione_evento_pubblico.pri_key={$evento_id}", $eo);
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

fgazza
Veteran Member
Posts: 205
Joined: 2019-04-30 17:37

Re: problem creating printable page

Post by fgazza » 2019-09-24 21:22

great! it seems to work! NNow i will continue to create my printable custom page. I will let you to know if I will encounter otrher problems!
For now... thank you so much!!!
Fabiano

Post Reply