Jump to content


Photo

PHP user Stranded in ASP world! HELP!!!


  • Please log in to reply
9 replies to this topic

#1 yeago

yeago
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 16 March 2006 - 06:28 PM

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:
<% 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
  %>

Please, tell me how to make this a simple foreach() in ASP.

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 16 March 2006 - 06:40 PM

ASP doesn't have a foreach() type function.

What's wrong with the code as-is?

Info: PHP Manual


#3 yeago

yeago
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 16 March 2006 - 06:47 PM

[!--quoteo(post=355618:date=Mar 16 2006, 06:40 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 16 2006, 06:40 PM) View Post[/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?

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 16 March 2006 - 06:56 PM

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.

Info: PHP Manual


#5 yeago

yeago
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 16 March 2006 - 06:59 PM

[!--quoteo(post=355624:date=Mar 16 2006, 06:56 PM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ Mar 16 2006, 06:56 PM) View Post[/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



#6 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 16 March 2006 - 07:16 PM

The first part is like using mysql_field_seek() ... the second part is like creating running $result = mysql_query() again.

Info: PHP Manual


#7 yeago

yeago
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 16 March 2006 - 07:19 PM

This is the simplest way to accomplish this task?

Never bothered with mysql_field_seek() =)

#8 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 16 March 2006 - 07:25 PM

Well, if you need to reset the recordset (not sure why you would want to), yeah.

Info: PHP Manual


#9 yeago

yeago
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 16 March 2006 - 07:26 PM

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?)

#10 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 16 March 2006 - 07:41 PM

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.

Info: PHP Manual





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users