Jump to content

Recommended Posts

Perhaps someone familiar with both ASP and PHP can help me understand some things about how ASP interacts with a SQL2000 database, as well as some syntax translations.

First problem:
[code]
<% if tempCounty <> 0  Then %>
<OPTION VALUE = "<%=tempCounty%>"><%=tempCountyValue%></OPTION>
<%
  end if
  While (NOT rscCountyList.EOF)
%>
<OPTION VALUE="<%=(rscCountyList.Fields.Item("CountyID").Value)%>"><%=(rscCountyList.Fields.Item("County").Value)%></OPTION>
<%
rscCountyList.MoveNext()
Wend
If (rscCountyList.CursorType > 0) Then
    rscCountyList.MoveFirst
Else
   rscCountyList.Requery
  End If
  %>
[/code]

Please, tell me how to make this a simple foreach() in ASP.
Link to comment
https://forums.phpfreaks.com/topic/5098-php-user-stranded-in-asp-world-help/
Share on other sites

[!--quoteo(post=355618:date=Mar 16 2006, 06:40 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 16 2006, 06:40 PM) [snapback]355618[/snapback][/div][div class=\'quotemain\'][!--quotec--]
ASP doesn't have a foreach() type function.

What's wrong with the code as-is?
[/quote]

It does in 10 lines what PHP does in 5?

Can you explain to me "Wend" and everything thereafter?
Yes, ASP is very inefficient.

Wend is "While End"... it's like closing a bracket on a while loop in PHP.... and yes, you must include it for one liners.

The if statement basically says "if the cursor (which is nothing more than a pointer in the recordset array) can use the MoveFirst call, do it.... otherwise run the query again to reset it at record 0".

Hope that helps.
[!--quoteo(post=355624:date=Mar 16 2006, 06:56 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 16 2006, 06:56 PM) [snapback]355624[/snapback][/div][div class=\'quotemain\'][!--quotec--]
The if statement basically says "if the cursor (which is nothing more than a pointer in the recordset array) can use the MoveFirst call, do it.... otherwise run the query again to reset it at record 0".
[/quote]

Break this down once more? =)

I'm very familiar with MySQL/PHP. Put in into those terms?

Thanks

By that do you mean go back through the records?

Also, what's this mean:

<% if tempCounty <> 0 Then %>
<OPTION VALUE = "<%=tempCounty%>"><%=tempCountyValue%></OPTION>
<% end if %>

Or more importantly. Why would it be there (perhaps its just machine generated junk?)
Yeah, like if you needed to reuse the recordset for another control or something.

I think that's just there so that if something was set in another part of the code, that it will be the first selection... although I don't see any "selected" attribute in the option. I'm assuming at this point without seeing more of the code.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.