CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 confirmation page with entered data displayed: PHP

Print topic Send  topic

Author Message
phpnewbie
Posted: 01/19/2002, 7:08 AM

can anybody provide an example for php+mysql?
i don't understand well enough article in T&T section about retrieving last inserted id (just look at my nick...:-)
Nicole
Posted: 01/21/2002, 1:27 AM

Hello,
in AfterInsert event add the code:
$last_id = mysql_insert_id();
set_session("last_id", $last_id);

Two lines only. Then you can access its value on any page and form. To get the session variable value use:
$may_var = get_session("last_id");
phpnewbie
Posted: 01/21/2002, 10:35 AM

ok, i have this in 'after insert', but my form doesn't transfer last_id value to next page.

on record form i have at this moment:
input tab: field: user_id, variable: last_id, type: param,operation: =, required, transfer.

on grid for display entered data i have:
input tab: field: user_id, variable: last_id, type: session, operation: =, required, transfer.

and after submitting form grid says "no data", and in browser address line there's no value of last_id, e.g. i have the following: /users_add_thx.php?last_id=

where is the mistake?
Nicole
Posted: 01/22/2002, 2:51 AM

Hello,
try to print generated sql on the Grid form. Open generated file, find the line:
$sSQL .= $sWhere . $sOrder;
right after it add print code:
echo $sSQL;

Post here whole sql query.
phpnewbie
Posted: 01/22/2002, 3:40 AM

select u.a_fax as u_a_fax, u.a_kod as u_a_kod, u.a_mail as u_a_mail, u.a_miasto as u_a_miasto, u.a_tel1 as u_a_tel1, u.a_tel2 as u_a_tel2, u.a_ulica as u_a_ulica, u.a_www as u_a_www, u.firma as u_firma, u.name as u_name, u.nip as u_nip, u.pass as u_pass, u.rodzaj_dystrybucja as u_rodzaj_dystrybucja, u.rodzaj_serwis as u_rodzaj_serwis, u.user as u_user, u.user_date as u_user_date, u.user_id as u_user_id, u.user_ip as u_user_ip from users_temp u


where my fields are: a_fax, a_kod and so on.
fields 'user_date' and 'user_ip' are hidden, I use them for logging submission date and IP number
phpnewbie
Posted: 01/22/2002, 12:57 PM

finally, i've got it:

i used following code in 'after insert' event:

$last_id = mysql_insert_id();
$sActionFileName .= "?user_id=".$last_id;

on record page input parameters variable name is 'user_id', transfer checkbox is UNCHECKED, type=param.
on grid page (which display relusts) variable for input is also 'user_id', but tansfer checkbox is CHECKED. user_id is of course my primary key.

works fine.
thank you, forum...

as i've found in topic 'Passing record id from a record form to another' on this forum:
"... $sActionFileName containes file name where you will be redirected after you submit the form. It's the same file name you set up as 'FormAction' in CC for the your Record form..."

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.