Okay, I want to show images according to the number of selected variables. For example, I have a checkbox set up of several choices (a, b, c, d, e) and then showing images for all 5, But this is not a problem. The trouble comes when the user only selects 3 of the 5. In the table 3 images will show but the other 2 will be broken images. is there a way to show only the images for the choices that the user selected without having broken images? Maybe something like a "if per variable show a,b,c,d, and e images"?
Mar 28, 1999, 5:38 AM
Veteran / Moderator (8669 posts)
Mar 28, 1999, 5:38 AM
Post #2 of 14
Views: 3475
I'm not sure I understand. I'll tell you how I think it is and you can tell me if I'm wrong.
A user adds a record and can choose up to 5 images to display with his record. You have fields named something like "imagea," "imageb," "imagec," etc. If the user wants only three of the images to be displayed with is record, then the fields "imaged" and "imagee" would be empty, while the other three would have the name of the image to be displayed. Have I got it right?
If so, it's just a matter of some "if" statements:
print qq|<img src="http://url/to/image directory/imagea">|;
}
if ($rec{'imageb'}) {
print qq|<img src="http://url/to/image directory/imageb">|;
}
And so on.
If I have completely misunderstood what you want to do, let me know and I'll see if I can come up with a different answer.
------------------
JPD
A user adds a record and can choose up to 5 images to display with his record. You have fields named something like "imagea," "imageb," "imagec," etc. If the user wants only three of the images to be displayed with is record, then the fields "imaged" and "imagee" would be empty, while the other three would have the name of the image to be displayed. Have I got it right?
If so, it's just a matter of some "if" statements:
Code:
if ($rec{'imagea'}) { print qq|<img src="http://url/to/image directory/imagea">|;
}
if ($rec{'imageb'}) {
print qq|<img src="http://url/to/image directory/imageb">|;
}
And so on.
If I have completely misunderstood what you want to do, let me know and I'll see if I can come up with a different answer.
------------------
JPD
Mar 28, 1999, 11:53 PM
User (365 posts)
Mar 28, 1999, 11:53 PM
Post #4 of 14
Views: 3493
Hey JP we got a little problem. Umm it doesn't like the "pipe sign" in the code. Plus it's popping out errors where the code is fine.
I tried putting this into a table within the HTML.pl for the Long VIEW. could it be the IF statements. I'm not that knowledgable about HTML.
any clues?
I tried putting this into a table within the HTML.pl for the Long VIEW. could it be the IF statements. I'm not that knowledgable about HTML.
any clues?
Mar 29, 1999, 6:14 AM
Veteran / Moderator (8669 posts)
Mar 29, 1999, 6:14 AM
Post #5 of 14
Views: 3486
Did you end off the previous print qq| statement before you started the if statements? (I tend to forget to mention it, but if you have a print qq| statement to print out the table formatting and other fields, you have to end it by adding |; before you start your if statements.)
That's the most likely problem from what you describe.
------------------
JPD
That's the most likely problem from what you describe.
------------------
JPD
Apr 2, 1999, 12:38 PM
User (365 posts)
Apr 2, 1999, 12:38 PM
Post #8 of 14
Views: 3491
Thanks JP, everything is fine but I was wondering can I do this with a check box format. ie, I have a check box setup of favorite fruits: apples, oranges, grapes and cherries. The user would pick whatever fruit they like. The data shows fine but how an I sepearte the data to show individual gifs for apples, oranges and cherries from the same data list. Or do I have to do it the hard way with radio boxes and input the data 1 by 1 so I can assign a gif to each individual variable.
Apr 2, 1999, 1:44 PM
Veteran / Moderator (8669 posts)
Apr 2, 1999, 1:44 PM
Post #9 of 14
Views: 3491
Again, I'm not real clear. What does the data look like in the field within the .db file? Are they all in one field, so it looks like:
apples~~cherries~~oranges
Or are they in separate fields:
apples|cherries|oranges
If it's the first way, you can say
if ($rec{'Fruit'} =~ "apples") {
print qq|<img src="http://URL/to/apples.gif">|;
}
if (rec{'Fruit'} =~ "cherries") }
print qq|<img src="http://URL/to/cherries.gif">|;
}etc.
If it's the second way, with each choice in its own field, it would be the way I showed you before.
------------------
JPD
apples~~cherries~~oranges
Or are they in separate fields:
apples|cherries|oranges
If it's the first way, you can say
Code:
|; if ($rec{'Fruit'} =~ "apples") {
print qq|<img src="http://URL/to/apples.gif">|;
}
if (rec{'Fruit'} =~ "cherries") }
print qq|<img src="http://URL/to/cherries.gif">|;
}
If it's the second way, with each choice in its own field, it would be the way I showed you before.
------------------
JPD
Apr 2, 1999, 4:35 PM
User (365 posts)
Apr 2, 1999, 4:35 PM
Post #10 of 14
Views: 3482
hmmm, I'm getting lost. but this is ok!
My data is settup as:
fruit = apples|oranges|apples
Well that's how it prints out (I'm really clueless here)
Your tilde (~) "apples~~cherries~~oranges" solution is what I'm looking for, being apple to split the data into different images. Is it possible to the if statements without the tilde sign anyways or do I have to redo my html.pl again?
Thanks JP
My data is settup as:
fruit = apples|oranges|apples
Well that's how it prints out (I'm really clueless here)
Your tilde (~) "apples~~cherries~~oranges" solution is what I'm looking for, being apple to split the data into different images. Is it possible to the if statements without the tilde sign anyways or do I have to redo my html.pl again?
Thanks JP
Apr 3, 1999, 6:19 AM
Veteran / Moderator (8669 posts)
Apr 3, 1999, 6:19 AM
Post #11 of 14
Views: 3468
The structure of apples~~cherries~~oranges is what your actual .db file would look like if you have a multiple select field. When you read the record, ~~ is translated into your delimiter, so that $rec{'Fruit'} becomes apples|cherries|oranges.
You should be able to use the
if ($rec{'Fruit'} =~ "apples") {
structure for your display. The operator =~ means "includes," so if your variable $rec{'Fruit'} includes anywhere in it the word "apples," your apple gif will print.
Ooh. I just got another idea. At the time of printing, your field is "apples|oranges|cherries" right? You can do this really slick, if you name your .gif files the same names as your options.
foreach $fruit (@fruits) {
print qq|<img src="http://URL/to/graphics/$fruit">|;
}
This even works correctly if there is no entry in $rec{'Fruits'}.
------------------
JPD
You should be able to use the
if ($rec{'Fruit'} =~ "apples") {
structure for your display. The operator =~ means "includes," so if your variable $rec{'Fruit'} includes anywhere in it the word "apples," your apple gif will print.
Ooh. I just got another idea. At the time of printing, your field is "apples|oranges|cherries" right? You can do this really slick, if you name your .gif files the same names as your options.
Code:
@fruits = split(/\|/,$rec{'Fruit'}); foreach $fruit (@fruits) {
print qq|<img src="http://URL/to/graphics/$fruit">|;
}
This even works correctly if there is no entry in $rec{'Fruits'}.
------------------
JPD
Apr 11, 1999, 3:44 PM
User (365 posts)
Apr 11, 1999, 3:44 PM
Post #12 of 14
Views: 3473
Hi JP, I've been trying what you suggested in your last post with slick version of printing images but now I'm getting a bunch of errors. 1.) do I have to use |; to stop the html and then use the @fruits method? 2.) you used @fruits and $rec{'fruit'} variables are they supposed to be different?
the debgging from DBMAN is popping out gibberish like:
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: syntax error at /home2/carsten/.//public_html/cgi-bin/dbman/html.pl line 301, near ""#cccccc" height"
syntax error at /home2/carsten/.//public_html/cgi-bin/dbman/html.pl line 316, near "DoorPrice
Which of course don't even exist. any clues?
the debgging from DBMAN is popping out gibberish like:
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: syntax error at /home2/carsten/.//public_html/cgi-bin/dbman/html.pl line 301, near ""#cccccc" height"
syntax error at /home2/carsten/.//public_html/cgi-bin/dbman/html.pl line 316, near "DoorPrice
Which of course don't even exist. any clues?
Apr 11, 1999, 3:53 PM
Veteran / Moderator (8669 posts)
Apr 11, 1999, 3:53 PM
Post #13 of 14
Views: 3478
Quote:
1.) do I have to use |; to stop the html and then use the @fruits method?Yes. That's a perl command, not something that goes directly on the webpage.
Quote:
2.) you used @fruits and $rec{'fruit'} variables are they supposed to be different?Yes. $rec{'fruit'} is the field in the record which holds your list of fruits. @fruits is an array that I made up to split the list into individual parts. The variable names don't have much to do with each other, but I intended to make them similar but a little different so you could tell them apart.
Quote:
[Errors] Which of course don't even exist. any clues?I'd start looking at line 301 and go backwards. Of course, it's probably within the "fruity" routine you added. Just from what you've posted, it looks to me like there may be a misplaced quotation mark or |.
If you want to post your html.pl script to your website, I'll take a look at it and see if I can find the error.
------------------
JPD
Apr 12, 1999, 2:21 AM
User (365 posts)
Apr 12, 1999, 2:21 AM
Post #14 of 14
Views: 3473
nah make that a
Ummm, I asked you about the stopping of the HTML but I completely forgot that I had to start it with the print qq| .... Dah that was rather lame of me.
interesting that a back slash turns out to be a YEN "\" mark on my Japanese made MAC.
All the things that went through my mind only to forget the basics. Thanks JP for getting me going again.
Ummm, I asked you about the stopping of the HTML but I completely forgot that I had to start it with the print qq| .... Dah that was rather lame of me.
interesting that a back slash turns out to be a YEN "\" mark on my Japanese made MAC.
All the things that went through my mind only to forget the basics. Thanks JP for getting me going again.