Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if else 1

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
SE
this S H O U L D give you two different outputs depending on "id". But somehow I get the same output for all.


Code:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("poetry.mdb")
Set RS = Conn.Execute("Select * From personal order by ID")
Do While Not RS.EOF
%>
    <% If Request.QueryString(&quot;id&quot;) <> RS(&quot;id&quot;) Then%> - <a href=&quot;poetry.asp?id=<%=RS(&quot;id&quot;)%>&quot;><%=RS(&quot;title&quot;)%></a> -<br>
    <% Else %> - <b>[ <%=RS(&quot;title&quot;)%> ]</b> - <br> <% End If %>
    <hr width=&quot;95&quot;>
    <%
    RS.MoveNext
Loop
End If
RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Try formatting your loop properly

Do While Not RS.EOF

If Request.QueryString(&quot;id&quot;) <> RS(&quot;id&quot;) Then%>
- <a href=&quot;poetry.asp?id=<%=RS(&quot;id&quot;)%>&quot;><%=RS(&quot;title&quot;)%></a> -<br>
<%Else%>
<b>[ <%=RS(&quot;title&quot;)%> ]</b> - <br>
<% End If %>

<hr width=&quot;95&quot;>
<%
RS.MoveNext
Loop Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
no changes =( but if I change Request.QueryString(&quot;id&quot;) with &quot;1&quot; then I will see the effect, on the one who holds the id = 1 My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
ru sure the variable ID is being passed correctly, try placing a response.write request.querystring(&quot;ID&quot;) in the above code Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
Yes I am sure, as you can see here: try clicking the links.
RS = RS(&quot;id&quot;) and QS = Request.QueryString(&quot;id&quot;)

I 100% sure that everything is OK My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Is the above code everything that is on the page? If not can you post the whole code Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
This is whole code for test.asp and I've tried everything from swapping place with both variables, assigning them to variables... etc.. printouts do fine, but they just won't play nice together =(
Code:
<%
Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & Server.MapPath(&quot;poetry/poetrydb.mdb&quot;)
Set RS = Conn.Execute(&quot;Select id,title From personal order by id&quot;)
Do While Not RS.EOF
    a = RS(&quot;id&quot;)
    b = Request.QueryString(&quot;id&quot;)
    %>
    RS<%=a %>
    QS<%=b%>
    <% If b <> a Then %> - <a href=&quot;test.asp?id=<%=RS(&quot;id&quot;)%>&quot;><%=RS(&quot;title&quot;)%></a> -
    <br>
    <% Else %> - <b>[ <%=RS(&quot;title&quot;)%> ]</b> - <br> <% End If %>
    <%
    RS.MoveNext
Loop
RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing
%>
My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
btw, I've even tried to change name in the database... without any luck! My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Got it, should have seen it straight away

set conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
strconn = &quot;DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=&quot; & Server.MapPath(&quot;poetrydb.mdb&quot;)
conn.Open strConn
set rs=Server.CreateObject(&quot;adodB.recordset&quot;)
RS.open &quot;Select recid,title From personal order by recid&quot;,conn
Do While Not RS.EOF
If int(Request(&quot;id&quot;)) <> RS(&quot;recid&quot;) Then%>
- <a href=&quot;test.asp?id=<%=RS(&quot;recid&quot;)%>&quot;><%=RS(&quot;title&quot;)%></a> -
<%Else%>
<b>[ <%=RS(&quot;title&quot;)%> ]</b> -
<% End If %>
<hr width=&quot;95&quot;><br>
<%
RS.MoveNext
Loop
RS.Close
Conn.Close
Set RS = Nothing
Set Conn = Nothing Saturday 12.00
im6.gif
im2.gif
im2.gif
20.00
im5.gif
im4.gif
im7.gif
3.00am
im8.gif
Sunday [img http
 
*phu*.. thank you so verry much =) now I can go to sleep *finaly* 0200

never thought that autonumber and querystring would be a problem.. perhaps all queryes are sent as text then?! =)

well.. many thanks again!! My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top