Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2007
    Posts
    46
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Converting a PHP file to ASP?

    I was wondering if I could convert this php file to asp.. Here's the code
    Code:
    <?php
    $id = $_GET['id'];
    ?>
      <?php
    if ($id=="")
     {
    ?>
             <li><a href="layouts.php?id=1">Layout 1</a></li>
       <li><a href="layouts.php?id=2">Layout 2</a></li>
     
    <?php
    }
    if ($id=="1")
      {
    ?>
    
       layout 1
           
         <?php
          }
          if ($id=="2")
          {
             ?>
    
       layout 2
    
           <?php
              }
                end
               ?>
    Thanks!

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by tylerh View Post
    I was wondering if I could convert this php file to asp..
    absolutely

    query string variables are accessed using the Request.QueryString(varName) and the if-then construct is as follows

    Code:
    if t = "" then
    end if
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New Coder
    Join Date
    Oct 2007
    Posts
    46
    Thanks
    7
    Thanked 0 Times in 0 Posts
    I tried this but i got an error
    I'm a n00b at asp coding
    haha

    Code:
    <%
    Request.QueryString(id)
     if id = "" then
       response.write("<a href='test.asp?id=1'>1</a> ;;;; <a href='test.asp?id=2'>2</a>")
    end if
      id id="1" then
     response.write("lol")
      end if
    if id="2" then
      response.write("rofl")
    end if
    %>
    :\

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Try
    Code:
    <%
    Dim t
    t = Request.QueryString("id")
     if t = "" then
       response.write("<a href='test.asp?id=1'>1</a> ;;;; <a href='test.asp?id=2'>2</a>")
    end if
      if t="1" then
     response.write("lol")
      end if
    if t="2" then
      response.write("rofl")
    end if
    %>

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    I'm not normally one for doing things for people rather than telling them how to do it, but as it is so simple:
    Code:
    <&#37;
    id = Request.QueryString("id")
    Select Case id
      Case "1"
        Response.Write "Layout 1"
    
      Case "2"
        Response.Write "Layout 2"
    
      Case Else
        %>
        <li><a href="layouts.asp?id=1">Layout 1</a></li>
        <li><a href="layouts.asp?id=2">Layout 2</a></li>
        <%
    
    End Select
    This could have been done with
    Code:
    If ... Then
      ...
    Else If ... Then
      ...
    Else If ... Then
      ...
    Else
      ...
    End If
    but Select Case makes this simpler.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •