2012-02-02 153 views
0

我試圖將這些函數從.asp文件轉換或轉換成.php函數,因爲我還不熟悉.asp。 其中一些我認識並可以理解,如SQL命令和遠程表中的數據將去的佔位符,其餘的都讓我感到困惑。 我已經轉換了一些如我認爲相當於PHP的include的include,';功能和其他幾個。有兩種語言的工作知識的人能告訴我哪些功能在哪裏?將asp函數轉換爲php

<!--#include virtual="/includes/functions.asp" --> 
<% 
intBusiness_Catagory = Request("select_catagory") 

Set thisConn = Server.CreateObject("ADODB.Connection") 
thisConn.Open CreateAfccDSN() 


SelectSQL = "SELECT * FROM BusinessInfo WHERE ((CatID = " & intBusiness_Catagory & ") or (CatID2 = " & intBusiness_Catagory & ") or (CatID3 = " & intBusiness_Catagory & ")) and (intStatusCodeID = 1) and (intOnWeb = 1) Order By vcBusinessName" 
Set SelectRs = thisConn.Execute(SelectSQL) 

If SelectRs.EOF Then 
    Response.Write("No members found for selected category.<br> Please search <a href='javascript:history.back()'>again</a>.") 
Else 
%> 
<b>Member Search Results:</b> 
<p> 

<% 
End If 

    If Not SelectRs.BOF AND Not SelectRs.EOF then 
     SelectRs.MoveFirst 
     Do Until SelectRs.EOF 
%> 
      <b><%=SelectRs("vcBusinessName") %></b><br> 
      <%=SelectRs("vcPhone") %><br> 
      <%=SelectRs("vcPAddress") %><br> 
      <%=SelectRs("vcPCity") %>, <%=SelectRs("vcPState") %>&nbsp;&nbsp;<%=SelectRs("vcPZipCode") %><br> 
      <% 
      If isNull(SelectRs("vcURL")) then 

      Else 
      %> 
       <b>Website: </b><a href="http://<%=SelectRs("vcURL") %>" target="_blank"><%=SelectRs("vcURL") %></a> 
      <% 
      End If 
      %> 
      <p> 
      <hr> 
<% 
      SelectRs.MoveNext 
     Loop 
%> 

<% 
    End If 

SelectRs.Close 
Set SelectRs = Nothing 
%> 
+2

沒有人會重新寫你對你的代碼。你不瞭解ASP代碼的哪些部分? – 2012-02-02 19:55:36

+0

主要是if語句,Rewrite語句,Set thisConn = Server.CreateObject,thisConn.Open,CreateAfccDSN()和intBusiness_Catagory。 – Tower 2012-02-02 20:05:42

回答

0

該腳本打開數據庫,進行查詢並從結果記錄中提取值。並非所有的東西都有1:1的PHP等價物。

Set thisConn = Server.CreateObject - 這將創建一個數據庫連接對象

thisConn.Open CreateAfccDSN() - 這將打開數據庫連接,利用一種稱爲CreateAfccDSN()函數,這裏沒有顯示傳回值。

intBusiness_Catagory = Request("select_catagory") - 這需要所謂select_catagory表單/ URL參數,並將其分配給本地變量intBusiness_Catagory

+0

好的謝謝!這應該幫助我。那麼重寫命令呢? – Tower 2012-02-02 20:20:39

+0

Response.Write = echo – 2012-02-02 20:24:04

+0

好吧,我明白了。儘管在代碼中沒有數據庫用戶和密碼的標誌,甚至沒有登錄過程。不確定這會對PHP有多好。 – Tower 2012-02-02 20:33:29