Simple PHP to ASP.net question!

Last post 05-09-2008 1:43 PM by soisasp. 2 replies.

Sort Posts:

  • Simple PHP to ASP.net question!

    05-07-2008, 4:35 PM
    • Loading...
    • soisasp
    • Joined on 03-17-2008, 12:41 PM
    • Posts 16

    How do I write this:

    $query = "select * from players";
    $aq = mysql_query($query) or die(mysql_error());
    while ($a = mysql_fetch_array($aq))
    {
      print $a[NAME] . "<br />";
    }

    in ASP.net?  Thanks! 


      
    I am a PHP programmer trying to convert to ASP.NET. Be kind!
  • Re: Simple PHP to ASP.net question!

    05-07-2008, 11:40 PM
    • Loading...
    • augustwind
    • Joined on 07-21-2002, 11:16 PM
    • Garland, TX
    • Posts 4,124
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    So, from what I can gather (and I know very little php), you're trying to query a database, and return a list of names from the players table, displaying them on the page, each followed by a line break, right?

    Well - there are so many ways to do this - you if you just want them on the page, you could set a Literal control or a Label control to the contents - or you could use a GridView or DataGrid, and it would be much easier.

    Take a look at some of these samples from ASPNet101.com:
    http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=dListdReader
    http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=drtest2
    http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=ddlTextValue

    More advanced (but showing what can be done):
    http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=MasterDetail20

    PHP (as well as Classic ASP) is a huge paradigm shift to ASP.Net. Everything in .Net is Object Oriented and Event Driven - much like you would program a Windows form, but do it in the web world.

    You click on a button - that's an event. The button has an even handler routine behind it, that fires when the button is clicked. You can make it display some names, fill a Dropdownlist, fill a Gridview with lots of information, etc.

    What is a simple scenario you'd like to do? We'll go from there.

    David Wier
    MVP/MCP/ASPInsider
    ASPNet101.com - where to look first!
    iWrite Pro - doc/rtft to HTML/One Click PDF & much more
  • Re: Simple PHP to ASP.net question!

    05-09-2008, 1:43 PM
    • Loading...
    • soisasp
    • Joined on 03-17-2008, 12:41 PM
    • Posts 16

     Thanks for your answer, it is amazingly helpful.  I think you hit the nail in the head with my issue.  The paradigm shift is what is giving me trouble.  I feel "boxed in" with ASP.net.  Everything feels canned and you can't really deviate much from it. 

     For example, I could do a grid view to get my data in the example, but what if I wanted to show passing stats (if a player is a QB) in the next cell and rushing stats (if a player is a RB) in the next cell?  What if I wanted the output to be like this:

     Joe Montana - 12 completions, 15 attempts, 166yards,  4 TD 0 int

    Bo Jackson - 10 attempts 450 yards, 1 TD
     

    I find learning how to do this very hard in ASP.net.  Is this the wrong language for me?  Can ASP.net be used with classic ASP?

    I understand the concept Event Driven well (i use javascript alot) but the OOP is still pretty new to me.  Thanks for the info, I will keep trying to learn! 

    I am a PHP programmer trying to convert to ASP.NET. Be kind!
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter