WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • Read data from database with code module.
  • Print
Pages: [1]   Go Down

Author Topic: Read data from database with code module.  (Read 7210 times)

Offline netraam

  • Posts: 47
Read data from database with code module.
« on: February 06, 2023, 04:06:40 PM »
Hello everyone,

Is it possible to read data from the websitabaker database with the code module?
And if it is so, does someone have an example how to do it?

Thanks in advance
Maarten
Logged

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: Read data from database with code module.
« Reply #1 on: February 06, 2023, 04:22:25 PM »
Write what you need from database ?
Logged
Web developer

Offline sternchen8875

  • Global Moderator
  • *****
  • Posts: 601
Re: Read data from database with code module.
« Reply #2 on: February 06, 2023, 05:39:46 PM »
take a look into the droplets and use echo (for a output) instead of return

for example this droplet for the last modified date from this page

Code: [Select]
global $database, $wb;
$retVal = ' ';
if (PAGE_ID > 0) {
    $query = $database->query("SELECT max(modified_when) FROM ".TABLE_PREFIX."pages");
    $mod_details = $query->fetchRow();
    $retVal = "This site was last modified on ".date("d/m/Y", $mod_details[0])." at ".date("H:i", $mod_details[0]).".";
}
echo $retVal;
Logged

Offline sternchen8875

  • Global Moderator
  • *****
  • Posts: 601
Re: Read data from database with code module.
« Reply #3 on: February 07, 2023, 12:05:06 AM »
additional info

it is not possible, to work with a code-combination between PHP && HTML or with other words: you cannot use the open PHP-Tag <?php and the endtag ?> in this code module

if you need a mixed code, use the Code² module -> https://addon.WebsiteBaker.org/pages/en/browse-add-ons.php?id=0C49DE21

this code²-Module is a stand-alone-module, it's not needed, to uninstall the WB-intern Code-Module, to use the Code²-Module
Logged

Offline netraam

  • Posts: 47
Re: Read data from database with code module.
« Reply #4 on: February 07, 2023, 03:49:47 PM »
It works,
Thanks for the info.

Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.13.x) »
  • General Help & Support »
  • Read data from database with code module.
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2