Page 1 of 1

display image stored in MYSQL in report

Posted: Fri Mar 23, 2012 2:26 am
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

Re: display image stored in MYSQL in report

Posted: Mon Mar 26, 2012 4:18 am
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

Re: display image stored in MYSQL in report

Posted: Mon Mar 26, 2012 8:55 am
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.

Re: display image stored in MYSQL in report

Posted: Tue Mar 27, 2012 2:08 am
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

Re: display image stored in MYSQL in report

Posted: Mon Apr 02, 2012 2:22 pm
by calvinp
Thanks. I got it working using your idea as a guide. :)

Re: display image stored in MYSQL in report

Posted: Tue Apr 03, 2012 12:05 am
by admin
Excellent!