Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 IF statement
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

schef
Junior Member

USA
164 Posts

Posted - 23 December 2002 :  10:51:56  Show Profile  Visit schef's Homepage  Send schef an AOL message
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

Posted - 23 December 2002 :  10:59:35  Show Profile  Visit D3mon's Homepage
Try:


if Request.ServerVariables("SCRIPT_NAME") = "default.asp" then


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

schef
Junior Member

USA
164 Posts

Posted - 23 December 2002 :  11:27:07  Show Profile  Visit schef's Homepage  Send schef an AOL message
no, no luck

ATV Outdoors
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 23 December 2002 :  11:32:51  Show Profile  Visit dayve's Homepage
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.

Go to Top of Page

schef
Junior Member

USA
164 Posts

Posted - 23 December 2002 :  11:36:20  Show Profile  Visit schef's Homepage  Send schef an AOL message
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
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 23 December 2002 :  11:48:59  Show Profile  Visit D3mon's Homepage
any error message appear?


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 11:50:24
Go to Top of Page

schef
Junior Member

USA
164 Posts

Posted - 23 December 2002 :  12:19:28  Show Profile  Visit schef's Homepage  Send schef an AOL message
no, no errors but the table in question just doesnt appear on any pages

ATV Outdoors
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 23 December 2002 :  12:23:26  Show Profile  Visit D3mon's Homepage
I've a hunch, try this..


if Request.ServerVariables("SCRIPT_NAME") = "\default.asp" then...



Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 23 December 2002 :  13:44:42  Show Profile
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

%>


Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 23 December 2002 :  13:51:18  Show Profile
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
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 23 December 2002 :  13:58:24  Show Profile  Visit D3mon's Homepage
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
Go to Top of Page

schef
Junior Member

USA
164 Posts

Posted - 23 December 2002 :  15:03:13  Show Profile  Visit schef's Homepage  Send schef an AOL message
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
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 23 December 2002 :  15:56:47  Show Profile
Add the statement in red as shown and see if it displays 'It Works!'


Response.write ("It Works!")
call MemInSpot()


Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 23 December 2002 :  16:07:05  Show Profile
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 <> ''"
Go to Top of Page

schef
Junior Member

USA
164 Posts

Posted - 23 December 2002 :  16:13:16  Show Profile  Visit schef's Homepage  Send schef an AOL message
same result as before :/

ATV Outdoors
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 23 December 2002 :  16:24:07  Show Profile
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.
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.38 seconds. Powered By: Snitz Forums 2000 Version 3.4.07