BullGuard Antivirus Sale - 60% Off with openElement !
Forum Home Forum Home >

openElement

> Dynamic OE - Databases, etc
  New Posts New Posts RSS Feed - PHP script to call DB  on Singel Text Box element
  FAQ FAQ  Forum Search   Register Register  Login Login

PHP script to call DB on Singel Text Box element

 Post Reply Post Reply
Author
Message
djju1029 View Drop Down
Senior Member
Senior Member
Avatar

Joined: Aug 02 2016
Location: the US
Status: Offline
Points: 126
Post Options Post Options   Thanks (0) Thanks(0)   Quote djju1029 Quote  Post ReplyReply Direct Link To This Post Topic: PHP script to call DB on Singel Text Box element
    Posted: Aug 29 2016 at 3:33pm
I made the PHP script to diaply DB value on single text box element.
In single text box

//Single box source
<div id="WEd7e0a2dcba" class="BaseDiv RWidth OEWETextBoxV2 OESK_WETextBox2_Default" style="z-index:1">
<div class="OESZ OESZ_DivContent OESZG_WEd7e0a2dcba">
<input name="name" type="text" class="OESZ OESZ_TextBox OESZG_WEd7e0a2dcba OEDynTag0" value="<?php include 'read.php'; ?>" />
</div>
</div>

//read.php
$db = new SQLite3('../../Data/Local_previs_DB/illu.db');
echo($db->querySingle('SELECT name FROM test_table WHERE id=12'));


When I use just one single text box, it can call succesfuly and display the singeDB value on text box.
But if two or more text box in page, how I can read for each text box element using same read.php?


Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group


Joined: May 31 2012
Status: Offline
Points: 5283
Post Options Post Options   Thanks (1) Thanks(1)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: Aug 30 2016 at 9:24am
Hi.

1) Don't modify the page code manually like this. You can apply the value using jQuery. Add a Code Block (Source) type Javascript, you can insert the reading PHP code directly inside:


<?php

//read.php
$db = new SQLite3('../../Data/Local_previs_DB/illu.db');
$read1 = $db->querySingle('SELECT name FROM test_table WHERE id=12');
$read2 = $db->querySingle('SELECT name FROM test_table WHERE id=16');
//etc.

?>

$(function(){ // on page structure loaded

  $('#WEd7e0a2dcba  input').val("<?php echo $read1 ?>");
  $('#SomeOtherID   input').val("<?php echo $read2 ?>");
  // etc.

});

Back to Top
djju1029 View Drop Down
Senior Member
Senior Member
Avatar

Joined: Aug 02 2016
Location: the US
Status: Offline
Points: 126
Post Options Post Options   Thanks (0) Thanks(0)   Quote djju1029 Quote  Post ReplyReply Direct Link To This Post Posted: Aug 30 2016 at 4:27pm
Thank you so much, Dmit! It works!Thumbs Up
Hmm.....I have to study jQuery too.....Cry
Back to Top
Dmit OE View Drop Down
Admin Group
Admin Group


Joined: May 31 2012
Status: Offline
Points: 5283
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dmit OE Quote  Post ReplyReply Direct Link To This Post Posted: Aug 30 2016 at 5:32pm
jQuery basics are very simple, just modify examples to your needs and make sure your code is inside $(function(){ .... }); to make it work only when the page is ready.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.047 seconds.