Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

PHP inside HTML

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

PHP inside HTML

Unread post by Janusz »

Hi,
I wanted to execute some php code inside the HTML but did not succeed.
So using the most basic code - how to place it inside nuBuilder to have it working.

Code: Select all

<!DOCTYPE html>
<html>
<body>
<p>First try with php:</p>

<?php
echo "My first PHP script!";
?>

</body>
</html>
If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 446 times
Contact:

Re: PHP inside HTML

Unread post by kev1n »

PHP code isn't interpreted when inserted into a HTML object. When you view the source of the page it still shows the php code.
What would you like to display?
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: PHP inside HTML

Unread post by Janusz »

Hi Kev1n,
I wanted to display some real photos of product inside the HTML box (so only photos for choosen product).
Photos are stored on server in one folder.
Names of photos and assignements to products are stored in mySQL table.
So depanding on the product I wanted to generate list of photos in mySQL and later to transfer it to nuBuilder JS to display them using directly path to photos.
So the biggest difficulty I had it was - how to tranfer mySQL data to JS or HTML inside nuBuilder.

But anyway finally I implemented following solutions which works very well now.

I use Object/Display field (name: pic_list) where the following query is placed (and read data from mySql)

Code: Select all

select 	fot_picture from fotos_all where fot_part_nr='#par_sample_id_number#'
Additional issue was that in such field only the first row is placed. So in Mysql I am generating view with long rows and in every row I have a list of all photos attached to one product.

Code: Select all

GROUP_CONCAT( DISTINCT ....  
later in JS I read the data from the display field and generate list of photos for HTML field

Code: Select all

var lista = $('#pic_list').val();
var temp=  "arr =['"+lista+"']";
var arr = eval(temp);
var holder = document.getElementById("holder");
for(var i=0; i < arr.length; i++)
holder.innerHTML += "<img src='./uploads/"+arr[i]+"' style='width:300px;'>";
and finally in HTML field just following short code is placed which displays all selected photos one after the other:

Code: Select all

<div id="holder"></div>
If you like nuBuilder, please leave a review on SourceForge
Post Reply