Previous Thread
Next Thread
Print Thread
Rate Thread
#323611 07/08/2021 1:07 AM
Joined: Jul 2021
Posts: 2
Tusk Offline OP
Lurker
OP Offline
Lurker
Joined: Jul 2021
Posts: 2
Hi,
Is there any way of doing db update, delete and insert in a custom Islands?

Sponsored Links
Tusk #323612 07/08/2021 11:14 AM
Joined: Jan 2000
Posts: 5,819
Likes: 16
UBBDev / UBBWiki Owner
Time Lord
Offline
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,819
Likes: 16
You can execute database queries in Custom Islands by following the syntax we utilize in the software (examples in the scripts you'll likely find helpful); an example would be the Random Image island at UBBCentral (this code is posted on that forum as well):
Code
/* PHP CODE HERE */
$query = "
	SELECT POST_ID, FILE_DIR, FILE_NAME
	FROM {$config['TABLE_PREFIX']}FILES
	WHERE (FILE_DIR <> '' AND FILE_DIR IS NOT NULL)
	  AND (FILE_TYPE = 'jpg'
	   OR FILE_TYPE = 'gif'
	   OR FILE_TYPE = 'jpg'
	   OR FILE_TYPE = 'jpeg'
	   OR FILE_TYPE = 'png')
	ORDER BY rand()
	LIMIT 1
";
$sth = $dbh->do_query($query, __LINE__, __FILE__);
list($postId, $fDir, $fName) = $dbh->fetch_array($sth);

/* BODY HERE */
$body = <<<EOF

<div class="acvt">
<div style="height:{$config['MAX_THUMB_W_H']}px;overflow:hidden;position:relative;width:100%;display:inline-block;">
<a href="{$config['BASE_URL']}/ubbthreads.php?ubb=showgallery&Number=$postId"><img src="{$config['BASE_URL']}/gallery/$fDir/medium/$fName" alt="" title="" class="p2 cp oi" style="position:absolute;left:-100%;right:-100%;top:-100%;bottom:-100%;margin:auto;max-width:280px;min-height:100%;"></a>
</div>
</div>

EOF;

Please be sure that your islands are set to cache their output to a reasonable value as short timings may result in strain on your database server depending on traffic trends.


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts
Gizmo #323613 07/09/2021 1:08 AM
Joined: Jul 2021
Posts: 2
Tusk Offline OP
Lurker
OP Offline
Lurker
Joined: Jul 2021
Posts: 2
HI,
We have two island that require a database updates, one is a game recruitment list with an two options to add or remove items from drop down lists, this requires and insert and delete. We also have an island that the users can generate dice rolls and the result is posted in the forum there in (so no cheating), this one generate a post and saves it. We have a few islands that just have lists of data like your random images, but we need to have the option to Update, Insert and Delete records, which do not appear work in an island.
Currently these two islands are written in Perl and work fine, I've been tasked with converting all of our Perl scripts to PHP as more and more ISP no-longer support Perl.

Last edited by Tusk; 07/09/2021 1:09 AM.
Tusk #323614 07/09/2021 4:42 PM
Joined: Jan 2000
Posts: 5,819
Likes: 16
UBBDev / UBBWiki Owner
Time Lord
Offline
UBBDev / UBBWiki Owner
Time Lord
Joined: Jan 2000
Posts: 5,819
Likes: 16
I generally only do SQL queries to pull data and use forms to post to other scripts which do processing.


UBB.Dev - Putting Dev into UBB.threads
Company: VNC Web Services - UBB.threads Scripts and Scripting, Install and Upgrade Services, Site and Server Maintenance.
Forums: A Gardeners Forum, Scouters World, and UGN Security
UBB.Threads: My UBB Themes, My UBB Scripts

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Bill B
Bill B
Issaquah, WA
Posts: 87
Joined: December 2001
Forum Statistics
Forums63
Topics37,557
Posts293,856
Members13,847
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,819
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 70
Gizmo 16
Brett 7
WebGuy 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2021 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Snapshot build 20210915)
Responsive Width:

PHP: 7.3.29 Page Time: 0.010s Queries: 23 (0.006s) Memory: 0.7993 MB (Peak: 0.8399 MB) Data Comp: Zlib Server Time: 2021-10-20 20:16:18 UTC
Valid HTML 5 and Valid CSS