Load Image From MySQL Database
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Load Image From MySQL Database
Needing to load images into DataGrid from MySQL database as needed.
I have written a query that gets the ID of the needed image. The required image is not in the table. The actual image is in a folder. The table only contains the names of the image and not their locations. The rest of the location needs to be prepended(appended to the front of) the name from the database.
My problem is how to load the needed image and have it appear in the DataGrid.
I have written a query that gets the ID of the needed image. The required image is not in the table. The actual image is in a folder. The table only contains the names of the image and not their locations. The rest of the location needs to be prepended(appended to the front of) the name from the database.
My problem is how to load the needed image and have it appear in the DataGrid.
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Load Image From MySQL Database
See the & operator.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Load Image From MySQL Database
I did. Plus went to the samples and tutorials without finding anything like this.
Here's what needs to happen: An image in a DataGrid field needs to change according to the id of the listing. The data for the listing is taken from multiple tables in one database. The table that references the images only has the name and not the location of the images. The tables are linked by their numbers. The images themselves are kept in an actual folder and are often changed and/or added to.
Here's what needs to happen: An image in a DataGrid field needs to change according to the id of the listing. The data for the listing is taken from multiple tables in one database. The table that references the images only has the name and not the location of the images. The tables are linked by their numbers. The images themselves are kept in an actual folder and are often changed and/or added to.
-
- VIP Livecode Opensource Backer
- Posts: 9842
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Load Image From MySQL Database
"&" is LiveCode's concatenation operator. I'm not familiar with tutorials on it, but since you have two things (path and file name) that need to be concatenated it seems a good fit.
Code: Select all
put "/home/user/me/somefolder/images" into tPath
put "123456.jpg" into tFileName
put tPath &"/"& tFileName into tFullPath
set the filename of image "MyImageDisplayObject" to tFullPath
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Load Image From MySQL Database
OK. Thank you. That looks like it will work.
Let me get the image to load from the id tho.
Let me get the image to load from the id tho.
-
- VIP Livecode Opensource Backer
- Posts: 7238
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Load Image From MySQL Database
It is easier to give the image object a name and refer to it that way. Then you don't need to mess around with IDs:
Or you can refer to it by number:
But if you really want to use your ID function (which seems like too much work and overhead to me, but...)
Code: Select all
set the filename of image "userPhoto" of me to tFullPath
Code: Select all
set the filename of image 1 of me to tFullPath
Code: Select all
set the filename of image ID tID of me to tFullPath
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Load Image From MySQL Database
Thanks.
I'm using the category ID number to match the event ID with the category ID. There is a different image associated with each category ID number. They are not in the same table. Looking at the DataGrid Tutorials and other stuff. Brigham Young University seems to have a lot of info also.
I'm using the category ID number to match the event ID with the category ID. There is a different image associated with each category ID number. They are not in the same table. Looking at the DataGrid Tutorials and other stuff. Brigham Young University seems to have a lot of info also.