Forums
This topic is locked
mutiple pics from one record???
Posted 06 Jul 2002 08:17:30
1
has voted
06 Jul 2002 08:17:30 Dave Clarke posted:
I have set up my database with a field that holds the path to a picture - fldpictures which holds the path pics/whatever.jpg, i can get this to display on my page no problem, question is can i have more than one pic in this field and get em all to display or do i have to add them all seperatley on the page??? how do i seperate them in fldpictures i.e pics/whatever.jpg;whatever2.jpgor pics/whatever.jpg,whatever2.jpg or pics/"whatever.jpg";"whatever2.jpg".
using access by the way
thanks
Dave
Replies
Replied 06 Jul 2002 14:57:49
06 Jul 2002 14:57:49 aegis kleais replied:
Hmmm. You could make the textbox contain multiple values of image URLS and then use some script to parse the field for commas, then import them into an array, which at the time of display, would then need a script to cycle through each array index and write the image.
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 06 Jul 2002 17:37:04
06 Jul 2002 17:37:04 Dave Clarke replied:
oh my god
far too complicated for me mate, think i will just allow one pic per message
much easier.
thanks
Dave
far too complicated for me mate, think i will just allow one pic per message
much easier.
thanks
Dave
Replied 06 Jul 2002 18:06:59
06 Jul 2002 18:06:59 Owen Eastwick replied:
How about storing a long string of HTML in the database image path field.
Soemthing like:
<img src="SomeDirectory/Pic1.gif"><br><img src="SomeDirectory/Pic2.gif"><br><img src="SomeDirectory/Pic3.gif"><br>
When the user browses to a new image to upload add the HTML around it and add it to the existing HTML string in the database image path field, something like:
varImage = RecordsetName.Fields.Item("ImagePath"
.Value & "<img src=""" & Request("FileBrowserBox"
& """><br>"
I haven't actually tried this so you may have to muck about with it a bit to get it working the way you want but it's an idea.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Soemthing like:
<img src="SomeDirectory/Pic1.gif"><br><img src="SomeDirectory/Pic2.gif"><br><img src="SomeDirectory/Pic3.gif"><br>
When the user browses to a new image to upload add the HTML around it and add it to the existing HTML string in the database image path field, something like:
varImage = RecordsetName.Fields.Item("ImagePath"


I haven't actually tried this so you may have to muck about with it a bit to get it working the way you want but it's an idea.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 06 Jul 2002 18:54:40
06 Jul 2002 18:54:40 nima mass replied:
The problem is that you MUST NOT have multiples values in the same field of a DB table. This mean that your database is not correctly designed. Try reading something about DB modeling before (ie: merise or UML).
And then you'll make more powerfull and faster requests...
And then you'll make more powerfull and faster requests...
Replied 06 Jul 2002 20:55:21
06 Jul 2002 20:55:21 Owen Eastwick replied:
I don't agree, I can think of many instances where you may wish to store multiple values in a single database field.
For example you may have a clothing products database in which you want to store the available sizes for each item: S, M, L, XL - surely you're not sugesting that each should be stored in a separate field with a yes/no value. With multiple values stored like this they can then be used in an array or even to be displayed as HTML, something like:
<%= Replace(RecordsetName.Fields.Item("Sizes"
.Value, ",", "<br>"
%>
You should be careful before making sweeping statements like "YOU MUST NOT", "NEVER" or "ALLWAYS" because there are ALWAYS exceptions to the rule.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
For example you may have a clothing products database in which you want to store the available sizes for each item: S, M, L, XL - surely you're not sugesting that each should be stored in a separate field with a yes/no value. With multiple values stored like this they can then be used in an array or even to be displayed as HTML, something like:
<%= Replace(RecordsetName.Fields.Item("Sizes"


You should be careful before making sweeping statements like "YOU MUST NOT", "NEVER" or "ALLWAYS" because there are ALWAYS exceptions to the rule.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 06 Jul 2002 23:39:59
06 Jul 2002 23:39:59 aegis kleais replied:
oeastwick
I like your idea. Just make the field the HTML and boom, Response.Writing it will print the images. Simple and should work fine (as long as the end user knows how to write the HTML!) (Why do I keep opting for the more difficult methods?) <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
I like your idea. Just make the field the HTML and boom, Response.Writing it will print the images. Simple and should work fine (as long as the end user knows how to write the HTML!) (Why do I keep opting for the more difficult methods?) <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Aegis Kleais
New Media Web Developer
(DWMX : IIS5.1 : SQL2K : WXP : ASP[VB/JS])
Replied 07 Jul 2002 04:06:03
07 Jul 2002 04:06:03 Owen Eastwick replied:
The end user doesn't have to know any HTML, use some script to add the HTML around the file name before adding it to the database:
varImage = RecordsetName.Fields.Item("ImagePath"
.Value & "<img src=""" & Request("FileBrowserBox"
& """><br>"
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
varImage = RecordsetName.Fields.Item("ImagePath"


Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 07 Jul 2002 05:51:32
07 Jul 2002 05:51:32 Dave Clarke replied:
oeastwick
The users wont actually be uploading the pics (server wont allow) but i will try the html string in the field and see what i can come up with.
thanks
Dave
The users wont actually be uploading the pics (server wont allow) but i will try the html string in the field and see what i can come up with.
thanks
Dave
Replied 07 Jul 2002 21:38:13
07 Jul 2002 21:38:13 Dave Clarke replied:
ok i have got the html in the field and it seems to work fine, now all i got to do is go through and take out all my dynamic pics and put the recordset field in instead.
only problem i had was in Access trying to set the default value for the field to <img src="pics/piccie.jpg"> but i got there eventually, had to put two sets of quotes in.
which reminds me, i need to add another field to my admin forms now, to update the picture path html.
oh well no rest for the wicked<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
only problem i had was in Access trying to set the default value for the field to <img src="pics/piccie.jpg"> but i got there eventually, had to put two sets of quotes in.
which reminds me, i need to add another field to my admin forms now, to update the picture path html.
oh well no rest for the wicked<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Replied 08 Jul 2002 12:20:15
08 Jul 2002 12:20:15 nima mass replied:
You should know that it's better to create a relational table to associate your clothing products, the available sizes, and the relation between them.
So you have 3 tables, the first is the "Product" and it mean the "product "entity, the second is the "available sizes" and mean the "available size" entity, the 3rd is the "exist" table wich mean a relation "exists in this size", not an entity (this relation is 1,n / 0,n wich mean that a product must exist into 1 or more size and that a size can describe none ore many products). The 3rd table made of 2 fields, the two identifiers from the tables "products" and " available sizes".
So a product can be associated with multiple sizes, a size can be associated with multiple products.
Tables :
product contain fields "id_product", "name" and any unique fields you want (description, price...)
Unique mean that the field represents a property of product that can't be sharded beetwen two products (ie: the name)
Size contain fields "id_size", "name" and many unique fields, you can imagine that you have a field showing the size into numeric format for 3 countrys. So you would have 3 fields "size_us","size_eu" and "size_jp" (for exemple, I'm not realy aware about clothes size over the world <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
exist is a relational table, it contain 2 fields to store the id of the products and of the associated size (it's called foreign keys)
Now, you can retrieve the sizes for a product (ie: <pre id=code><font face=courier size=2 id=code> SELECT id_size FROM exist WHERE id_product = @myProductId
or even directly retrive the size label using a join :
SELECT size.name FROM exist, size WHERE id_product = @myProductId AND exist.id_size=size.id_size
</font id=code></pre id=code>
you can also retrieve all the products available into one or more sizes
(ie: <pre id=code><font face=courier size=2 id=code> SELECT id_product FROM exist WHERE id_size BETWEEN @minSize AND @maxSize
</font id=code></pre id=code>
And many more things...
Using this design method, you avoid NULL fields and fields containing more that one value.
It IS the wright way to design databases.
So I can keep making sweeping statements like "YOU MUST NOT", "NEVER" or "ALLWAYS" because databases are made to be designed using this stapements.
This statements are called "normal forms", there are a few of them and they are the bases of our modern relational databases.
Have a look, you'll see that it's very interesting and that it will give you the keys to more powerfull uses of databases. (things you can't do without design methods)
Regards.
Nico (ready to help for this if you want)
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I don't agree, I can think of many instances where you may wish to store multiple values in a single database field.
For example you may have a clothing products database in which you want to store the available sizes for each item: S, M, L, XL - surely you're not sugesting that each should be stored in a separate field with a yes/no value. With multiple values stored like this they can then be used in an array or even to be displayed as HTML, something like:
<%= Replace(RecordsetName.Fields.Item("Sizes"
.Value, ",", "<br>"
%>
You should be careful before making sweeping statements like "YOU MUST NOT", "NEVER" or "ALLWAYS" because there are ALWAYS exceptions to the rule.
Regards
Owen.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
So you have 3 tables, the first is the "Product" and it mean the "product "entity, the second is the "available sizes" and mean the "available size" entity, the 3rd is the "exist" table wich mean a relation "exists in this size", not an entity (this relation is 1,n / 0,n wich mean that a product must exist into 1 or more size and that a size can describe none ore many products). The 3rd table made of 2 fields, the two identifiers from the tables "products" and " available sizes".
So a product can be associated with multiple sizes, a size can be associated with multiple products.
Tables :
product contain fields "id_product", "name" and any unique fields you want (description, price...)
Unique mean that the field represents a property of product that can't be sharded beetwen two products (ie: the name)
Size contain fields "id_size", "name" and many unique fields, you can imagine that you have a field showing the size into numeric format for 3 countrys. So you would have 3 fields "size_us","size_eu" and "size_jp" (for exemple, I'm not realy aware about clothes size over the world <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
exist is a relational table, it contain 2 fields to store the id of the products and of the associated size (it's called foreign keys)
Now, you can retrieve the sizes for a product (ie: <pre id=code><font face=courier size=2 id=code> SELECT id_size FROM exist WHERE id_product = @myProductId
or even directly retrive the size label using a join :
SELECT size.name FROM exist, size WHERE id_product = @myProductId AND exist.id_size=size.id_size
</font id=code></pre id=code>

you can also retrieve all the products available into one or more sizes
(ie: <pre id=code><font face=courier size=2 id=code> SELECT id_product FROM exist WHERE id_size BETWEEN @minSize AND @maxSize
</font id=code></pre id=code>

And many more things...
Using this design method, you avoid NULL fields and fields containing more that one value.
It IS the wright way to design databases.
So I can keep making sweeping statements like "YOU MUST NOT", "NEVER" or "ALLWAYS" because databases are made to be designed using this stapements.
This statements are called "normal forms", there are a few of them and they are the bases of our modern relational databases.
Have a look, you'll see that it's very interesting and that it will give you the keys to more powerfull uses of databases. (things you can't do without design methods)
Regards.
Nico (ready to help for this if you want)
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I don't agree, I can think of many instances where you may wish to store multiple values in a single database field.
For example you may have a clothing products database in which you want to store the available sizes for each item: S, M, L, XL - surely you're not sugesting that each should be stored in a separate field with a yes/no value. With multiple values stored like this they can then be used in an array or even to be displayed as HTML, something like:
<%= Replace(RecordsetName.Fields.Item("Sizes"


You should be careful before making sweeping statements like "YOU MUST NOT", "NEVER" or "ALLWAYS" because there are ALWAYS exceptions to the rule.
Regards
Owen.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>