This topic is locked
[SOLVED]

 Delete all button

7/4/2011 7:08:22 AM
PHPRunner General questions
buddy author

First let me say what an excellent product this is.
I have added a "delete all" button to the List page using the following:
<input type=button class=button value="Delete All" onclick="window.location.href='Source_list.php?delete=all';">
The problem: nothing happens when I click it.
Any help would be appreciated.
Buddy

C
cgphp 7/4/2011

Hi buddy,
from the visual editor, on the list page, insert a new button:
http://xlinesoft.com/phprunner/docs/inserting_button.htm
In the "Client before" section type the code for a confirm message.
In the "Server" section type the code, using a query, to delete all records.
In the "Client after" section type the code for alert the user with a message: "all records deleted".

buddy author 7/4/2011



Hi buddy,
from the visual editor, on the list page, insert a new button:
http://xlinesoft.com...ting_button.htm
In the "Client before" section type the code for a confirm message.
In the "Server" section type the code, using a query, to delete all records.
In the "Client after" section type the code for alert the user with a message: "all records deleted".


This is the part I'm having a problem with.
---

In the "Server" section type the code, using a query, to delete all records.

---
I saw another post indicating I should use:
if request.querystring("delete")="all" then

dbConnection.Execute "delete from Source"
but cannot seem to get the syntax to work right. I get
syntax error, unexpected T_STRING, expecting '(' in line 2
Thanks for the help
Buddy

C
cgphp 7/4/2011

If you are using PHPrunner and not ASPrunner:
Client before:

ctrl.setEnabled();

if( ! confirm("Do you want to delete all records ?"))

return false;


Server:

global $strTableName;

$sql = "delete from ".$strTableName;

CustomQuery($sql);

$result['page_redirection'] = $strTableName."_list.php";


Client after:

alert("All record deleted");

location.href = result['page_redirection'];
buddy author 7/4/2011

Thanks cgphp.
The Client before pops up the window ok, but no records are deleted. Tried IE and Firefox.
I appreciate your help
Buddy

C
cgphp 7/4/2011

Try this for the server section:



global $conn,$strTableName;

$sql = "DELETE FROM ".$strTableName;

db_exec($sql,$conn);

$result['page_redirection'] = $strTableName."_list.php";
buddy author 7/4/2011



Try this for the server section:



global $conn,$strTableName;

$sql = "DELETE FROM ".$strTableName;

db_exec($sql,$conn);

$result['page_redirection'] = $strTableName."_list.php";



Thanks but same result. No records are deleted.
I'm assuming $strTableName is changed to $strSource although no records were deleted either way.
Buddy

C
cgphp 7/4/2011

Try this non-parametric solution:



global $conn;

$sql = "DELETE FROM your_table_name";

db_exec($sql,$conn);

$result['page_redirection'] = "your_table_name_list.php";
buddy author 7/4/2011

Still no result after clicking OK in popup.
Buddy

C
cgphp 7/4/2011

Probably, there are some errors in your app.

Run firebug before click the button and check the debug info.

buddy author 7/4/2011

Firebug returns:
JSON.parse

throw new SyntaxError('JSON.parse');};}}());
I should have mentioned before that I have "Before record deleted" event that adds the record to another table. Is it possible that is what may be causing the problem?
Event code is:
{

global $conn;

$str = "select * from Source where ".$where;

$rs = db_query($str,$conn);

$data = db_fetcharray($rs);
$strSQLInsert = "insert into AllData (Company,First,Last,Email,Website,Salutation,Middle,Suffix,Title,Function,Phone,Mobile,Fax,Address1,Address2,Address3,City,State,Zip,Country,Campaign,Listset,Industry) values ('".$data["Company"]."','".$data["First"]."', '".$data["Last"]."', '".($value = $data["First"].'
'.$data["Last"]."@".$data["Website"])."', '".$data["Website"]."','".$data["Salutation"]."','".$data["Middle"]."','".$data["Suffix"]."','".$data["Title"]."','".$data["Function"]."','".$data["Phone"]."','".$data["Mobile"]."','".$data["Fax"]."','".$data["Address1"]."','".$data["Address2"]."','".$data["Address3"]."','".$data["City"]."','".$data["State"]."','".$data["Zip"]."','".$data["Country"]."','".$data["Campaign"]."','".$data["Listset"]."','".$data["Industry"]."')";
db_exec($strSQLInsert,$conn);
return true;

}

buddy author 7/4/2011

I deleted that event and got the same result.

C
cgphp 7/4/2011

Post a demo without the "Before record deleted" event set.