Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

display image stored in MYSQL in report

Locked
calvinp
Posts: 4
Joined: Wed Mar 21, 2012 12:56 pm

display image stored in MYSQL in report

Unread post by calvinp »

Hi,

New to nuBuilder and find it one of the best web database builder around.

Hope someone could help me with this.

I am building a staff database.
I have pictures stored in MYSQL for each staff record.

For displaying picture in the edit record page, i have done successfully by modifying the SCimage code and display using image ID, ie
<img id="theimage" src="">

However I can't do the same in the report designer by using <img id="theimage" src=""> as label.

How can I have the picture of the employee for each record printed out in the report?


Example:

Employee Report
--------------------------
Employee 1 Name
Employee 1 Contact Number
Employee 1 Photo Image

--------------------------

Employee 2 Name
Employee 2 Contact Number
Employee 2 Photo Image
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: display image stored in MYSQL in report

Unread post by admin »

calvinp,

Although it hasn't been documented yet there is a way to do it.

create a field with a value of <img src='formimage.php?dir=db/sample&iid=149bf07777e6a0'>

with iid being the image's id

and run the report displaying that as a field

Hopefully that makes sense, but it will only work as a html report.

Its the way used to display the banner on the index page.

Steven
calvinp
Posts: 4
Joined: Wed Mar 21, 2012 12:56 pm

Re: display image stored in MYSQL in report

Unread post by calvinp »

Thanks Steven for your idea and quick reply. Hope you can help me further in details.

By putting <img src='formimage.php?dir=db/sample&iid=theimageid'> as HTML label in the record builder object, I will be calling only one image only and all records will be displaying the same picture ( which is not I want, as each employee record in the report should have their own picture displayed)


What I need is theimageid has to be a variable, which the report builder grab from blob entry of each record and display it.

In the edit record page I have JavaScript code
function nuLoadThis(){
document.getElementById('theimage').src=getImage_em(document.getElementById('recordID').value);
}
to call this.

I cannot seems to think of how since the report object label only accepts simple HTML with no variable code, and there is no JavaScript field i can place codes as report objects.

I am new to this and a bit amateur in the programming. Really hope you can help. How do I go about this?

Thanks again for your kind assistance.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: display image stored in MYSQL in report

Unread post by admin »

calvinp,

What I was suggesting was to use a field not a label.

Just the same way as you might create a field in #dataTable# for fullname by concatenating first and last names.

eg.

Code: Select all

SELECT employee.*, CONCAT("<img src='formimage.php?dir=db/sample&iid=",cus_image_id, "theimageid'>") AS their_head FROM employee

I hope this makes sense.

Steven
calvinp
Posts: 4
Joined: Wed Mar 21, 2012 12:56 pm

Re: display image stored in MYSQL in report

Unread post by calvinp »

Thanks. I got it working using your idea as a guide. :)
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: display image stored in MYSQL in report

Unread post by admin »

Excellent!
Locked