将 asp 函数转换为 php

发布于 2025-01-02 02:25:25 字数 1885 浏览 0 评论 0原文

我正在尝试将这些函数从 .asp 文件翻译或转换为 .php 函数,因为我还不熟悉 .asp 。 其中一些我认识并且可以理解,例如 SQL 命令和来自远程表的数据所在的占位符,其余的让我感到困惑。 我已经转换了一些,例如 include,我相信它相当于 PHP 的 include '';功能和其他几个。精通两种语言的人可以告诉我哪些函数在哪里吗?

<!--#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
%>

I am attempting to translate or convert these functions from a .asp file into .php functions as i am not familiar with .asp as of yet.
Some of them i recognize and can comprehend such as the SQL commands and the placeholders where data from the remote table would go, and the rest have my confused.
I have already converted some such as the include which i believe is the equivalent to PHP's include ''; function and several others. Could someone with working knowledge of both languages show me which functions go where?

<!--#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") %>  <%=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
%>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

╰つ倒转 2025-01-09 02:25:25

该脚本打开数据库,进行查询并从结果记录中吐出值。并非这里的所有内容都有 1:1 PHP 等价物。

Set thisConn = Server.CreateObject - 这将创建一个数据库连接对象

thisConn.Open CreateAfccDSN() - 这将打开数据库连接,使用从名为 CreateAfccDSN( 的函数) 传回的值),此处未显示。

intBusiness_Catagory = Request("select_catagory") - 这采用名为 select_catagory 的表单/url 参数,并将其分配给本地变量 intBusiness_Catagory

This script opens a database, makes a query and spits out values from the resulting records. Not everything here has a 1:1 PHP equivalent.

Set thisConn = Server.CreateObject - this creates a database connection object

thisConn.Open CreateAfccDSN() - This opens the database connection, using values passed back from a function called CreateAfccDSN(), which is not shown here.

intBusiness_Catagory = Request("select_catagory") - This takes a form/url parameter called select_catagory and assigns it to the local variable intBusiness_Catagory

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文