Print Page | Close Window

How can reloading the page after DB updating

Printed From: openElement Website
Category:

openElement


Forum Name: Dynamic OE - Databases, etc
Forum Description: openElement's database management system and Element Packs
URL: https://forums.openelement.uk/en/forum_posts.asp?TID=824
Printed Date: Apr 19 2024 at 1:02pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How can reloading the page after DB updating
Posted By: djju1029
Subject: How can reloading the page after DB updating
Date 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



Replies:
Posted By: Dmit OE
Date Posted: Sep 08 2016 at 10:55am
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?


Posted By: djju1029
Date Posted: Sep 08 2016 at 3:07pm
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?


Posted By: Dmit OE
Date Posted: Sep 09 2016 at 1:36am
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.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net