Jump to content

Archived

This topic is now archived and is closed to further replies.

yeago

PHP user Stranded in ASP world! HELP!!!

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.

Share this post


Link to post
Share on other sites
ASP doesn't have a foreach() type function.

What's wrong with the code as-is?

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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

Share this post


Link to post
Share on other sites
The first part is like using mysql_field_seek() ... the second part is like creating running $result = mysql_query() again.

Share this post


Link to post
Share on other sites
This is the simplest way to accomplish this task?

Never bothered with mysql_field_seek() =)

Share this post


Link to post
Share on other sites
Well, if you need to reset the recordset (not sure why you would want to), yeah.

Share this post


Link to post
Share on other sites
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?)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.