Author |
Topic  |
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 13 December 2003 : 21:31:55
|
quote: Originally posted by Alfred
I can't believe it, I made a wild guess, and it works! quote: Function DisplayMedalIcon(m_id, alttext, altdate)
Are you then using altdate in the function ? |
 |
|
Alfred
Senior Member
   
USA
1527 Posts |
Posted - 13 December 2003 : 21:43:47
|
No, I use the date field. quote: DisplayMedalIcon = DisplayMedalIcon & "<img border=""0"" src=""../images/gold.gif"" width=""66"" height=""90"" alt="""&myMedalMembers("scenario") & myMedaLMembers("Medal_date") & """>"
Thats why it floored me when it worked! As a matter of fact it even works when I just put "date": quote: Function DisplayMedalIcon(m_id, alttext, date)
Amazing, when one considers that usually things have to be "just so" in coding! |
Alfred The Battle Group CREDO
|
Edited by - Alfred on 13 December 2003 22:01:47 |
 |
|
Alfred
Senior Member
   
USA
1527 Posts |
|
snaayk
Senior Member
   
USA
1061 Posts |
Posted - 14 December 2003 : 01:13:18
|
You're not using the function properly. Remember, once within the function refer to the function variables that you defined within the parenthesis, not external variables which may not be what is expected. Thus, change the code in blue to the code in red:
Function DisplayMedalIcon(m_id, alttext, date)
Function DisplayMedalIcon(m_id, alttext, strdate)
alt="""&myMedalMembers("scenario") & myMedalMembers("Medal_date") & """
alt=""" & alttext & " " & strdate & """
You'll noticed I changed the variable date to strdate in the function. This is because date is a reserved word and you should not use it unless calling the date() function for the current date.
Also, I added a space within the alt text between the scenario and the date. You can add a colon, dash, or anything else you might want. Basically, just more readable, but the code would have worked. |
 |
|
Alfred
Senior Member
   
USA
1527 Posts |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 14 December 2003 : 01:55:20
|
it's because of the whole structure of that page. this is what you are doing now:
1. sql statement that pulls member id, scenario, medal, etc. from the database. 2. do loop that iterates through the records from 1. 3. inside the loop you have an if statement that determines whether or not to display something. this if statement will basically only display for the first record brought back from each member. therefore, only the first scenario is considered for that member as well. 4. for that first record only, you call a function that displays all the member's medals. this function does so by executing yet another sql that pulls back only the medal ids.
what you should do is consider revising either your original do loop or you function as a whole. if i were doing it, i would revise both actually. i'd make it so that the function didn't have to execute yet another sql. then, i'd revise the response.write code inside the do loop to determine whether or not it needs to move onto a new member (hence new table cell and row).
As a side note, it looks like you need to redo the do loop code anyway. you are writing a body tag in it. unless you only have one member, the code will write the body tag several times and there should only be one body tag on a page. if i'm not mistaken, inc_header already has a body tag in it anyway.
your page also does not have a closing body tag, nor have you included inc_footer which is really bad, as you are leaving the connection to the database open. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
Edited by - Nikkol on 14 December 2003 01:58:36 |
 |
|
Alfred
Senior Member
   
USA
1527 Posts |
Posted - 14 December 2003 : 12:56:17
|
Ok, Nikkol - I can do one of the things you point out right now, which is to include the inc_footer. The other stuff is probably over my head...  |
Alfred The Battle Group CREDO
|
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
|
Alfred
Senior Member
   
USA
1527 Posts |
Posted - 14 December 2003 : 13:44:05
|
Thanks, Nikkol - do you want me to upload another txt file? |
Alfred The Battle Group CREDO
|
 |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 14 December 2003 : 14:13:58
|
Here's what I came up with based on your last file. I think it should work:
<meta http-equiv="Page-Enter" content="RevealTrans(Duration=3,Transition=5)">
<meta http-equiv="Page-Exit" content="RevealTrans(Duration=3,Transition=4)">
<!--#INCLUDE FILE="config.asp"-->
<!--#INCLUDE FILE="inc_header.asp" -->
<%
'## display all defense medals #############################################################
response.write "<hr>Medals by country:"&"<br><br>"
response.write "German medals: " & "<img border=""0"" src=""../images/gold.gif"" width=""22"" height=""30"">" & _
"<img border=""0"" src=""../images/silver.gif"" width=""22"" height=""30"">" & _
"<img border=""0"" src=""../images/bronze.gif"" width=""22"" height=""30"">    "
response.write "USSR medals: " & "<img border=""0"" src=""../images/med_ussr_gold.JPG"" width=""22"" height=""30"">" & _
"<img border=""0"" src=""../images/med_ussr_silv.JPG"" width=""22"" height=""30"">" & _
"<img border=""0"" src=""../images/med_ussr_bron.jpg"" width=""22"" height=""30"">    "
response.write "UK medals: " & "<img border=""0"" src=""../images/med_uk_gold.JPG"" width=""22"" height=""30"">" & _
"<img border=""0"" src=""../images/med_uk_silv.JPG"" width=""22"" height=""30"">" & _
"<img border=""0"" src=""../images/med_uk_bron.jpg"" width=""22"" height=""30"">    "
response.write "US medals: " & "<img border=""0"" src=""../images/med_us_gold.JPG"" width=""22"" height=""30"">" & _
"<img border=""0"" src=""../images/med_us_silv.JPG"" width=""22"" height=""30"">" & _
"<img border=""0"" src=""../images/med_us_bron.jpg"" width=""22"" height=""30"">    <hr>"
'## start of medalsfunction.asp file code #################################################
'Function DisplayMedalIcon(m_id)
Function DisplayMedalIcon(m_id, medal_id, alttext, strdate)
DisplayMedalIcon = ""
Dim medalImage(18)
medalImage(3) = "med_ussr_bron.jpg"
medalImage(4) = "med_ussr_silv.jpg"
medalImage(5) = "med_ussr_gold.jpg"
medalImage(6) = "bronze.gif"
medalImage(7) = "silver.gif"
medalImage(8) = "gold.gif"
medalImage(9) = "med_uk_bron.jpg"
medalImage(10) = "med_uk_silv.jpg"
medalImage(11) = "med_uk_gold.jpg"
medalImage(12) = "med_us_bron.jpg"
medalImage(13) = "med_us_silv.jpg"
medalImage(14) = "med_us_gold.jpg"
medalImage(16) = "1stargold.jpg"
medalImage(17) = "2stargold.jpg"
medalImage(18) = "3stargold.jpg"
DisplayMedalIcon = "<img border=""0"" src=""../images/" & medalImages(CInt(medal_id)) & """ " & _
"width=""66"" height=""90"" alt=""" & alttext & " " & strdate & """>"
End Function
'############################################
'## get indiviual medals for players #################################################
strSql = "SELECT MEMBER_MEDALS.MEMBER_ID, MEMBER_MEDALS.MEDAL_ID, MEMBER_MEDALS.SCENARIO, " & _
"MEMBER_MEDALS.MEDAL_DATE, FORUM_MEMBERS.M_NAME, FORUM_MEMBERS.M_COUNTRY FROM FORUM_MEMBERS " & _
"INNER JOIN MEMBER_MEDALS ON FORUM_MEMBERS.MEMBER_ID = MEMBER_MEDALS.MEMBER_ID order by M_NAME ASC;"
set myMedalMembers = my_Conn.Execute(strSql)
currid = 0
do while not myMedalMembers.eof
strPlayerName = myMedalMembers("M_NAME") '## to set up links in names ################
numPLayerID = myMedalMembers("MEMBER_ID") '###########################################
intMedalID = myMedalMembers("MEDAL_ID")
strCountry = myMedalMembers("M_COUNTRY")
strScenario = myMedalMembers("SCENARIO")
medalDate = myMedalMembers("MEDAL_DATE")
If currid <> numPlayerID then
response.write "<br><div align=""center"">"
response.write "<table bgcolor=""#37008A"" border=""5"" cellpadding=""5"" cellspacing=""0"" " & _
"style=""border-collapse: collapse"" bordercolorlight=""#FFFFCC"" " & _
"bordercolordark=""#666600"" bgcolor=""#000000"">"
response.write "<tr><td width=""100%"" align=""center"">"
response.write profileLink(strPlayerName, numPlayerID)
response.write "<br><img border=""0"" src="""&"../images/"&replace(strCountry," ","") &".gif""><br>"
End If
response.write DisplayMedalIcon(numPlayerID, intMedalID, strScenario, medalDate)
If currid <> numPlayerID then
response.write "</td></tr></table></center></div>"
End If
currid = numPlayerID
myMedalMembers.movenext
loop
%>
<!--#INCLUDE FILE="inc_footer.asp" -->
|
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
 |
|
Alfred
Senior Member
   
USA
1527 Posts |
Posted - 14 December 2003 : 14:21:35
|
I replaced the total file with yours and came up with a "Type mismatch": quote: Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: 'medalImages' /BG/forums/decorated.asp, line 44
|
Alfred The Battle Group CREDO
|
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
Posted - 14 December 2003 : 14:30:35
|
Line 44 - change the word medalImages to medalImage
IMHO, if you're rewriting the page, I would also remove the hard-coded medalImage array and create a table instead. That way you don't have to change the code each time your medal list changes. Then change the DisplayMedalIcon function to load the array once, making it so only if the array is empty do you execute the SQL. |
 |
|
Alfred
Senior Member
   
USA
1527 Posts |
Posted - 14 December 2003 : 15:01:32
|
Thanks, laser. This produced all medals. ALthough I seem to have something wrong in the table coding, because only one of each player's medals is within the table frame. |
Alfred The Battle Group CREDO
|
 |
|
laser
Advanced Member
    
Australia
3859 Posts |
|
Nikkol
Forum Moderator
    
USA
6907 Posts |
Posted - 14 December 2003 : 15:32:24
|
i agree with laser and making a table for the medals, where you could store the id, name, and the image file. but since it seems he does not have that currently, i replaced all the if statements with an array instead. a little easier to read and less code. |
Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~ |
 |
|
Topic  |
|