Author |
Topic |
schef
Junior Member
USA
164 Posts |
Posted - 23 December 2002 : 10:51:56
|
I am trying to write an if statement that will allow me to show a table on only default.asp. Is there a way to test what page the user is seeing?
The reason why is because I have tables setup in my inc_header.asp that I only want displayed on default.asp |
ATV Outdoors |
|
D3mon
Senior Member
United Kingdom
1685 Posts |
|
schef
Junior Member
USA
164 Posts |
Posted - 23 December 2002 : 11:27:07
|
no, no luck |
ATV Outdoors |
|
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 23 December 2002 : 11:32:51
|
quote: Originally posted by schef
no, no luck
show us what you tried, because that will work... of course you'll need to add an end if at the end of your conditional statement. |
|
|
|
schef
Junior Member
USA
164 Posts |
Posted - 23 December 2002 : 11:36:20
|
here it is:
<%
if Request.ServerVariables("SCRIPT_NAME") = "default.asp" then
Response.write "<table width=""150"" border=""0"" cellspacing=""0"" cellpadding=""0"" bgcolor=""black"">" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td align=""left"" valign=""top"">" & vbCrLf & _
" <table BORDER=""0"" bordercolor=""" & strHeadCellColor & """ cellspacing=""1"" cellpadding=""0"" width=""100%"">" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td valign=""top"">" & vbCrLf & _
" <table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"">" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td align=""center"" bgcolor=" & strHeadCellColor & ">" & vbCrLf & _
" <table width=""100%"" cellpadding=""2"">" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td valign=""top"" align=""center""><font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""2""><b>Member Spotlight</b></font></td>" & vbCrLf & _
" </tr>" & vbCrLf & _
" </table>" & vbCrLf & _
" </td>" & vbCrLf & _
" </tr>" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td bgcolor=""" & strForumCellColor & """>" & vbCrLf & _
" <table border=""0"" width=""100%"" cellspacing=""0"" cellpadding=""2"">"
'START MEMBER IN SPOTLITE SCRIPT
function MemInSpot
set rsMemInSpot = Server.CreateObject("ADODB.Recordset")
strSql = "SELECT " & strTablePrefix & "MEMBERS.MEMBER_ID, " & strTablePrefix & "MEMBERS.M_PHOTO_URL, " & strTablePrefix & "MEMBERS.M_NAME, "
strSql = strSql & strTablePrefix & "MEMBERS.M_FIRSTNAME, " & strTablePrefix & "MEMBERS.M_LASTNAME, " & strTablePrefix & "MEMBERS.M_AGE"
strSql = strSql & " FROM " & strTablePrefix & "MEMBERS"
strSql = strSql & " WHERE FORUM_MEMBERS.M_PHOTO_URL <> ''"
rsMemInSpot.Open strSql, my_Conn,3,,adCmdText
Dim intRnd
Randomize Timer
intRnd = (Int(RND * rsMemInSpot.RecordCount))
rsMemInSpot.Move intRnd
strMemInSpot = rsMemInSpot("M_PHOTO_URL")
Response.Write " <tr><td align=center bgcolor=""" & strForumCellColor & """>" & vbCrLf & _
" <a href=""" & strForumURL & "pop_profile.asp?mode=display&id="& rsMemInSpot("member_id") & """><font face=""" & strDefaultFontFace & """ color=""" & strDefaultFontColor & """ size=""" & strDefaultFontSize & """><b>" & rsMemInSpot("M_NAME") & "</b></font></A><br>" & vbCrLf
if Trim(rsMemInSpot("M_PHOTO_URL")) <> "" and lcase(rsMemInSpot("M_PHOTO_URL")) <> "http://" then
if lcase(left(strMemInSpot,7)) = "http://" then
Response.write " <a href=" & ChkString(rsMemInSpot("M_PHOTO_URL"), "display")& ">" & vbCrLf & _
" <img src=" & ChkString(rsMemInSpot("M_PHOTO_URL"), "display") & vbCrLf
elseif lcase(left(strMemInSpot,7)) <> "http://" then
Response.write " <a href=" & strForumURL & "images/" & ChkString(rsMemInSpot("M_PHOTO_URL"), "display")& ">" & vbCrLf & _
" <img src=" & strForumURL & "images/" & ChkString(rsMemInSpot("M_PHOTO_URL"), "display")& vbCrLf
end if
Response.write " alt=" & ChkString(rsMemInSpot("M_NAME"),"display")& vbCrLf & _
" width=""120"" height=""120"" border=""0"" hspace=""0"" vspace=""4""></a><br>" & vbCrLf
else
Response.Write getCurrentIcon(strIconPhotoNone,"No Photo Available","hspace=""0"" vspace=""4""") & "<br>" & vbCrLf _
end if
Response.Write " <a href=""" & strForumURL & "pop_profile.asp?mode=display&id="& rsMemInSpot("member_id") & """><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>" & rsMemInSpot("M_NAME") & "'s Profile</font></A><br>" & vbCrLf
Response.Write " </td></tr>"
rsMemInSpot.Close
Set rsMemInSpot = Nothing
end function
'END MEMBER IN SPOTLITE SCRIPT
call MemInSpot
Response.Write " </td>" & vbCrLf & _
" </tr>" & vbCrLf & _
" </table>" & vbCrLf & _
" </td>" & vbCrLf & _
" </tr>" & vbCrLf & _
"</table>" & vbCrLf & _
"</td>" & vbCrLf & _
"</tr>" & vbCrLf & _
"</table>" & vbCrLf & _
"</td>" & vbCrLf & _
"</tr>" & vbCrLf & _
"</table>"
end if
%>
|
ATV Outdoors |
|
|
D3mon
Senior Member
United Kingdom
1685 Posts |
|
schef
Junior Member
USA
164 Posts |
Posted - 23 December 2002 : 12:19:28
|
no, no errors but the table in question just doesnt appear on any pages |
ATV Outdoors |
|
|
D3mon
Senior Member
United Kingdom
1685 Posts |
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 23 December 2002 : 13:44:42
|
Try this
<%
if Instr(strScriptName, "default.asp") > 0 then
Response.write "<table width=""150"" border=""0"" cellspacing=""0"" cellpadding=""0"" bgcolor=""black"">" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td align=""left"" valign=""top"">" & vbCrLf & _
" <table BORDER=""0"" bordercolor=""" & strHeadCellColor & """ cellspacing=""1"" cellpadding=""0"" width=""100%"">" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td valign=""top"">" & vbCrLf & _
" <table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"">" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td align=""center"" bgcolor=" & strHeadCellColor & ">" & vbCrLf & _
" <table width=""100%"" cellpadding=""2"">" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td valign=""top"" align=""center""><font face=""" & strDefaultFontFace & """ color=""" & strHeadFontColor & """ size=""2""><b>Member Spotlight</b></font></td>" & vbCrLf & _
" </tr>" & vbCrLf & _
" </table>" & vbCrLf & _
" </td>" & vbCrLf & _
" </tr>" & vbCrLf & _
" <tr>" & vbCrLf & _
" <td bgcolor=""" & strForumCellColor & """>" & vbCrLf & _
" <table border=""0"" width=""100%"" cellspacing=""0"" cellpadding=""2"">"
call MemInSpot()
Response.Write " </table></td>" & vbCrLf & _
" </tr>" & vbCrLf & _
" </table>" & vbCrLf & _
" </td>" & vbCrLf & _
" </tr>" & vbCrLf & _
"</table>" & vbCrLf & _
"</td>" & vbCrLf & _
"</tr>" & vbCrLf & _
"</table>" & vbCrLf & _
"</td>" & vbCrLf & _
"</tr>" & vbCrLf & _
"</table>"
end if
'START MEMBER IN SPOTLITE SCRIPT
function MemInSpot()
set rsMemInSpot = Server.CreateObject("ADODB.Recordset")
strSql = "SELECT " & strTablePrefix & "MEMBERS.MEMBER_ID, " & strTablePrefix & "MEMBERS.M_PHOTO_URL, " & strTablePrefix & "MEMBERS.M_NAME, "
strSql = strSql & strTablePrefix & "MEMBERS.M_FIRSTNAME, " & strTablePrefix & "MEMBERS.M_LASTNAME, " & strTablePrefix & "MEMBERS.M_AGE"
strSql = strSql & " FROM " & strTablePrefix & "MEMBERS"
strSql = strSql & " WHERE FORUM_MEMBERS.M_PHOTO_URL <> ''"
rsMemInSpot.Open strSql, my_Conn,3,,adCmdText
Dim intRnd
Randomize Timer
intRnd = (Int(RND * rsMemInSpot.RecordCount))
rsMemInSpot.Move intRnd
strMemInSpot = rsMemInSpot("M_PHOTO_URL")
Response.Write " <tr><td align=center bgcolor=""" & strForumCellColor & """>" & vbCrLf & _
" <a href=""" & strForumURL & "pop_profile.asp?mode=display&id="& rsMemInSpot("member_id") & """><font face=""" & strDefaultFontFace & """ color=""" & strDefaultFontColor & """ size=""" & strDefaultFontSize & """><b>" & rsMemInSpot("M_NAME") & "</b></font></A><br>" & vbCrLf
if Trim(rsMemInSpot("M_PHOTO_URL")) <> "" and lcase(rsMemInSpot("M_PHOTO_URL")) <> "http://" then
if lcase(left(strMemInSpot,7)) = "http://" then
Response.write " <a href=" & ChkString(rsMemInSpot("M_PHOTO_URL"), "display")& ">" & vbCrLf & _
" <img src=" & ChkString(rsMemInSpot("M_PHOTO_URL"), "display") & vbCrLf
elseif lcase(left(strMemInSpot,7)) <> "http://" then
Response.write " <a href=" & strForumURL & "images/" & ChkString(rsMemInSpot("M_PHOTO_URL"), "display")& ">" & vbCrLf & _
" <img src=" & strForumURL & "images/" & ChkString(rsMemInSpot("M_PHOTO_URL"), "display")& vbCrLf
end if
Response.write " alt=" & ChkString(rsMemInSpot("M_NAME"),"display")& vbCrLf & _
" width=""120"" height=""120"" border=""0"" hspace=""0"" vspace=""4""></a><br>" & vbCrLf
else
Response.Write getCurrentIcon(strIconPhotoNone,"No Photo Available","hspace=""0"" vspace=""4""") & "<br>" & vbCrLf _
end if
Response.Write " <a href=""" & strForumURL & "pop_profile.asp?mode=display&id="& rsMemInSpot("member_id") & """><font face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """>" & rsMemInSpot("M_NAME") & "'s Profile</font></A><br>" & vbCrLf
Response.Write " </td></tr>"
rsMemInSpot.Close
Set rsMemInSpot = Nothing
end function
'END MEMBER IN SPOTLITE SCRIPT
%>
|
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 23 December 2002 : 13:51:18
|
quote: Originally posted by GauravBhabu
Try this
if Instr(strScriptName, "default.asp") > 0 then
Gaurav, is the strScriptName variable specified somewhere already so you can reuse it, or does it have to be defined? If it's not already defined, you can also replace strScriptName with Request.ServerVariables("SCRIPT_NAME") Never mind. strScriptName is defined in inc_header.asp. Just so this reply isn't entirely useless: Gaurav's code (the part I quoted) should work as I use it a lot and it's never failed me. |
Edited by - Roland on 23 December 2002 13:54:21 |
|
|
D3mon
Senior Member
United Kingdom
1685 Posts |
Posted - 23 December 2002 : 13:58:24
|
ASP Tip:
Calling the script name from a pre-defined variable (e.g. strScriptName) is much faster than using the request object every time in your ASP page. |
Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod "In war, the victorious strategist only seeks battle after the victory has been won" |
Edited by - D3mon on 23 December 2002 14:00:27 |
|
|
schef
Junior Member
USA
164 Posts |
Posted - 23 December 2002 : 15:03:13
|
Ok, I am not sure why this is, but nothing is working. It will either show up on all pages, or not show up at all. I have tried:
if Left(Request.ServerVariables("SCRIPT_NAME"), Len(Request.ServerVariables("SCRIPT_NAME"))-1) = "default.asp" then
if lcase(Request.ServerVariables("SCRIPT_NAME")) = "default.asp" then
If InStr(Request.ServerVariable("SCRIPT-NAME"), "default.asp") Then
If LCase(Request.ServerVariables("SCRIPT_NAME")) = "/default.asp" Then
if Instr(strScriptName, "default.asp") > 0 then
All with no luck
|
ATV Outdoors |
Edited by - schef on 23 December 2002 15:03:54 |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 23 December 2002 : 15:56:47
|
Add the statement in red as shown and see if it displays 'It Works!'
Response.write ("It Works!")
call MemInSpot()
|
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 23 December 2002 : 16:07:05
|
I think the code works but seems to be not working because of the where condition in the sql
strSql = strSql & " WHERE FORUM_MEMBERS.M_PHOTO_URL <> ''" |
|
|
schef
Junior Member
USA
164 Posts |
Posted - 23 December 2002 : 16:13:16
|
same result as before :/ |
ATV Outdoors |
|
|
GauravBhabu
Advanced Member
4288 Posts |
Posted - 23 December 2002 : 16:24:07
|
Does any of your members have provided Picture URL in their profile? A link to the site will be helpful with a test username and password. |
|
|
Topic |
|