[PHP]Last Clan Created

Results 1 to 10 of 10
  1. #1
    Doggie And Rice. Military is offline
    MemberRank
    Jun 2009 Join Date
    Here and AboutLocation
    3,301Posts

    [PHP]Last Clan Created

    Hello , I was working on this script out of the idea of this and because I'm trying to get better at PHP. It was a pain doing this for a newbie like me but after some references from Google and Secured I got it done.

    Script
    Code:
    <?php
    
    // Newest Clan - Military
    
    $_MSSQL[Host]               = "\SQLEXPRESS";
    $_MSSQL[User]               = "sa";
    $_MSSQL[Pass]               = "";
    $_MSSQL[DBNa]               = "GunzDB";
    
    $r = mssql_connect($_MSSQL[Host], $_MSSQL[User], $_MSSQL[Pass]) or die("Cant connect to database");
    mssql_select_db($_MSSQL[DBNa], $r) or die("Selection Failed");
    
    $newclan = mssql_query("SELECT TOP 1 * FROM CLAN WHERE DeleteFlag = 0 ORDER BY regdate DESC");
    $row = mssql_fetch_row($newclan);
    
    if(mssql_num_rows($newclan) != 1) {
    	echo "No Data!";
    	}
    	else
    	{
    	echo "The Last Clan Created was $row[1] and it was created on $row[9]";
    	}
    
    ?>
    Screenshot



    Credits
    Secured - Showing me how to get it done after countless mistakes(Didnt use your way)
    iCreamPie(Rodi) - Making the script and from where I took the idea
    Google - Helping Me along the way
    SuperWaffle - Giving me deleteflag.

    Please Click The Like Button + Rep If You Like
    Last edited by Military; 10-12-11 at 03:34 AM.


  2. #2
    Pee Aitch Pee Dave is offline
    MemberRank
    Mar 2011 Join Date
    The NetherlandsLocation
    722Posts

    Re: [PHP]Last Clan Created

    Tip: If you want faster queries then select the column(s) which you want to use/show.

    SELECT TOP 1 * FROM CLAN ORDER BY regdate DESC
    becomes
    SELECT TOP 1 Name FROM CLAN ORDER BY regdate DESC

    Maybe also change the query so it will not show a deleted clan. :)

  3. #3
    Doggie And Rice. Military is offline
    MemberRank
    Jun 2009 Join Date
    Here and AboutLocation
    3,301Posts

    Re: [PHP]Last Clan Created

    Quote Originally Posted by SuperWaffle View Post
    Tip: If you want faster queries then select the column(s) which you want to use/show.

    SELECT TOP 1 * FROM CLAN ORDER BY regdate DESC
    becomes
    SELECT TOP 1 Name FROM CLAN ORDER BY regdate DESC

    Maybe also change the query so it will not show a deleted clan. :)
    Thanks for the tips bro.

  4. #4
    Die() Secured is offline
    MemberRank
    Sep 2011 Join Date
    /home/SDev/Location
    555Posts

    Re: [PHP]Last Clan Created

    ;) Your getting better haha <3

  5. #5
    Doggie And Rice. Military is offline
    MemberRank
    Jun 2009 Join Date
    Here and AboutLocation
    3,301Posts

    Re: [PHP]Last Clan Created

    Updated it not to include deleted clans , thanks to SuperWaffle.

  6. #6
    Account Upgraded | Title Enabled! TalkingBot is offline
    MemberRank
    Dec 2011 Join Date
    TheHostingsquadLocation
    213Posts

    Re: [PHP]Last Clan Created

    nice. its useful

  7. #7
    Apprentice Choroupaarou is offline
    MemberRank
    Dec 2010 Join Date
    16Posts

    Re: [PHP]Last Clan Created

    This is very easy.
    Still worth O_o

  8. #8
    Doggie And Rice. Military is offline
    MemberRank
    Jun 2009 Join Date
    Here and AboutLocation
    3,301Posts

    Re: [PHP]Last Clan Created

    Quote Originally Posted by Choroupaarou View Post
    This is very easy.
    Still worth O_o
    I'm doing tiny scripts as I haven't got a website to code.

  9. #9
    Apprentice Choroupaarou is offline
    MemberRank
    Dec 2010 Join Date
    16Posts

    Re: [PHP]Last Clan Created

    Quote Originally Posted by Military View Post
    I'm doing tiny scripts as I haven't got a website to code.
    So good luck :)

  10. #10
    Hi, I'm Omar! Vusion is offline
    MemberRank
    Jan 2011 Join Date
    HereLocation
    1,658Posts

    Re: [PHP]Last Clan Created

    Code:
    echo "The Last Clan Created was $row[1] and it was created on $row[9]";
    Would be nicer and easier if you'd insert the row's name in quotation(strings)

    Code:
    echo "The Last Clan Created was $row["Name"] and it was created on $row["RegDate"]";



Advertisement