This topic is locked
[SOLVED]

 Update Multiple Records

1/12/2013 9:58:04 PM
PHPRunner General questions
W
wfcentral author

I have a table for client to track time for his employees. Each record has a drop down for status that links to a table with three options in it (pending, approved, disapproved). In the actual timesheet table these are stored as values 1,2,3. So, I'm linking these two tables to display the word "pending" for example.
a SIMPLE example would be
table_time (id, status_ID, name, time, client)

table_status (id, status_name)
My client asked if I can make it so he can rapidly approve multiple lines.
Obviously, he could select all rows and edit inline... then he is going to have to change the dropdown in each line from pending to approved.
He wants something a little quicker where he can just check off each row and then click a button that says "Approve" and they all change from pending status to approved.
Two ways I have thought about approaching it is to hand-code this part or to try and integrate a form into the actual listing page that would post that data to an update page.
Any ideas?

C
cgphp 1/13/2013

You can get inspiration from this article: http://xlinesoft.com/phprunner/docs/update_multiple_records.htm

W
wfcentral author 1/13/2013

that appears to be exactly what I need. I inserted it into my list page following all the instructions and when I click the button nothing happens. No error. No change in the listing.
Is there a way to put some type of error checking in it or possibly have it display the sql statement so I can make sure it is getting the right variables?
// SERVER TAB //

global $dal;

for ($i=0; $i<count($keys); $i++)

{

//set Approved field to 2 (approved) if selected

$sql = "Update tbl_time_expense set approved='2' where id=".$keys[$i]["id"];

CustomQuery($sql);

}
$result["txt"] = "Records were updated.";
// CLIENT AFTER TAB //

var message = result["txt"];

ctrl.setMessage(message);

C
cgphp 1/14/2013
W
wfcentral author 1/14/2013



You can debug the code usign firebug for firefox or developer tools for Chrome. Check these articles: http://xlinesoft.com/blog/2012/05/16/troubleshooting-custom-buttons-in-phprunner-and-asprunnerpro-applications/, http://xlinesoft.com/phprunner/docs/troubleshooting_javascript_errors.htm


I followed the debug steps. I get nothing in firebug when I press my button. It appears the button is not firing. I also added the line to see the sql results in the browser and I see nothing happen. It appears my button is non-functional.

C
cgphp 1/14/2013

Something is breaking the button. Could you post a demo link to your app?

W
wfcentral author 1/14/2013

I found the issue finally and got this working.
Problem: When doing updates to clients projects I tend to build it in a new folder (with version number). Then, when it is bug free I give them the link to the new location.
Apparently, the code generated for the button feature was not fully uploading.
A full build and full upload fixed the issue.
thanks!