How can reloading the page after DB updating |
Post Reply |
Author | |
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
Posted: Sep 07 2016 at 10:26pm |
Dear openElement,
I go just step by step with your help. Thanks. I want to figure out how reload the page after DB updating through submit form? That means I want to change the page with updating DB value? DJ |
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(0)
|
Hi,
Do you use the Send Form element? Can you use the same page ("Active Page" in the "tree" of the link configuration dialog), so that it loads the page and passes the data to it, and use PHP scripts (or include your existing PHP script) to process it? |
|
djju1029
Senior Member Joined: Aug 02 2016 Location: the US Status: Offline Points: 126 |
Post Options
Thanks(0)
|
1. Yes, I use Submit Form element.
2. I use php script directly for instance: LOCAL: test/manual_scripting/update.php //update.php <?php $db = new PDO('sqlite:../../Data/Local_previs_DB/illu.db'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $data = array(); $data[0] = $_POST['WE50467f8358']; $data[1] = $_POST['WEd7e0a2dcba']; $data[2] = $_POST['WE778b0b2dec']; $stmt = array(); for ($i=0; $i<=2; $i++) { $j = $i + 1; $stmt[$i] = $db->prepare("UPDATE test_table SET name=(:name) WHERE id='$j'"); $stmt[$i]->bindParam(':name', $data[$i]); $stmt[$i]->execute(); } ?> Could you let me know how I can update DB using the same page (Current Page) and php scripts both? Edited by djju1029 - Sep 08 2016 at 4:05pm |
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(0)
|
It's hard to say without having your project. Add something like this to a Code Block Source type PHP position StartDocument on your page:
if (isset($_POST['WE50467f8358'])) { require_once ('test/manual_scripting/update.php'); // check the path; this will include+execute your script } Then use the link to the same page (ex. LOCAL: #) in the Send Form configuration, rather than your script. And make sure you have PHP code that gets values from DB on this page - I think you already have it in place. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |