This topic is locked

Go to Last Record

1/19/2011 3:52:22 PM
PHPRunner General questions
bbarker author

I've read a lot of postings, but didn't see how to apply them to this "simple" scenario.
I start on the LIST page.

Then go to the ADD page to add a new record.

When done, I want the "AFTER RECORD ADDED" EVENT to return to the LIST page, but show the newly added record.
Is there a global variable that I should use?

//********** Redirect to another page ************

header("Location: list.php");

exit();
bbarker author 1/20/2011
//FOLLOWING TWO LINES ADDED

header("Location: tblvendors_list.php?editid1=$values["VendorID"]");

exit();


Error Message:

Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING


It is a single quote, double quote, single quote.

But the line doesn't have any single quotes in it?!?!?
I'm trying to follow the advice in this posting:

http://www.asprunner.com/forums/topic/14233-go-to-edit-page-after-adding-new-record-in-masterchild-record/

J
Jane 1/20/2011

Hi,
to redirect to the list page use simple:

header("Location: tblvendors_list.php?a=return");

exit();


To rdirect to the view page of current record use this code:

header("Location: tblvendors_list.php?editid1=".$keys["VendorID"]);

exit();
bbarker author 1/20/2011

Thanks Jane.
The good news is that my NEW record saves correctly.
The bad news is that it still leaves me at the ADD page - with the fields filled in from the previous entry.
So it looks like everything works, except for the "redirect".
I don't assign the Vendor ID until the record is saved. It is an auto-increment field.

Is that an issue?

L
lil33 1/20/2011

To get the last record you added use this php function in after record added event
function AfterAdd($values,$keys,$inline)

{

$s=mysql_insert_id();

and then put the variable in header function

header("Location: page_view.php?editid1=$s");

my regards

bbarker author 1/21/2011

Thanks for posting... but that didn't work either.
I have removed the reference to skip the last record, and it won't even redirect to the FIRST record... so obviously I've got something else wrong.
Here's the current event -- and it saves the added new record, but stays on the add_page. And the data remains in the form... That must be an indication of SOMETHING??!?!? ha.

// After record added

function AfterAdd($values,$keys,$inline)

{



//********** Redirect to another page ************

header("Location: tblvendors_list.php");

exit();
// Place event code here.

// Use "Add Action" button to add code snippets.

;

} // function AfterAdd


I even added the "return true" to see if that wold make it work.

// After record added

function AfterAdd($values,$keys,$inline)

{



//********** Redirect to another page ************

header("Location: tblvendors_list.php");

exit();
return true;
// Place event code here.

// Use "Add Action" button to add code snippets.

;

} // function AfterAdd
V
Vienna 1/22/2011

I have this scenario working for me right now on the 'Details' view. I have a Master table of doctor's records and a detail table where the forms are submitted to a 'details' table. In my case with five users, each one has a details/forms table assigned just to their own records. So user A on logging in is submitting forms to "user_a_details". User B submits forms to "user_b_details', so to speak.
User A has just two tabs....the Doctor's records (master table) and "Reports User A" (only using that person's name).
So when User A submits reports in the pop-up form they are written immediately to "user_a_details". As soon as she submits the form when it disappears off the screen she immediately sees it sitting at the top of the other forms. Every form she fills in immediately shows up in front of her at the top of the rows in the Lists view.
I simply assigned an auto-increment "reporting_id" int(10)unique index field as the first field so that every report gets an auto-incremented number that keeps getting higher, obviously, with every record. Then in the PHPRunner query designer for the ADD Form I assigned "reporting_id" as the first field. And I specified that it was sorted in DESCENDING order by 1.
Now the added form shows up in the List page as the Top of the listed records immediately. And every form in that user's session keeps showing up at the top with the preceding forms listed chronologically earlier below it.
Simple answer for a nice result.

bbarker author 1/22/2011

Thanks... That's a great idea to have my LIST page sorted by Descending ID. Then when you go to the page, you'll always see the most recent record.
But my problem is different -- I don't seem to get the auto-redirect EVENT to work properly. Even when I put it in the ADD page, exactly how the Instruction Tutorial says, it won't redirect back to the LIST page.
I guess that I'll have to bundle this up and send it in or an evaluation.

If you have any further ideas, please post here. (Does it have anything to do with the LIST page also displaying a DETAILS page?)