About SQL Commands

Results 1 to 10 of 10
  1. #1
    Account Upgraded | Title Enabled! maxgo1 is offline
    MemberRank
    Aug 2008 Join Date
    EST , PaldiskiLocation
    311Posts

    About SQL Commands

    What Command i should use that MSSQL Displays only in table in column 'WorldIDX' Bloody Ice
    Attached Thumbnails Attached Thumbnails tnx.jpg  


  2. #2
    The Dinosaur chumpywumpy is offline
    MemberRank
    Jun 2008 Join Date
    /f451/Location
    5,127Posts

    Re: About SQL Commands

    Code:
    select [name],lev,worldidx from dbo.cabal_character_table where worldidx=1 and login=1
    ;)

  3. #3
    Account Upgraded | Title Enabled! maxgo1 is offline
    MemberRank
    Aug 2008 Join Date
    EST , PaldiskiLocation
    311Posts

    Re: About SQL Commands

    no-no .. i mean if WorldIDX is 1 that in Table is writed by "Bloody Ice"
    if WorldIDX is 2 that in Table is writed by "Desert"
    if WorldIDX is 3 that in Table is writed by "Green Despair"

  4. #4
    The Cat in the Hat cypher is offline
    MemberRank
    Oct 2005 Join Date
    IrelandLocation
    5,073Posts

    Re: About SQL Commands

    many curses about that... does it really bother you?

  5. #5
    Account Upgraded | Title Enabled! maxgo1 is offline
    MemberRank
    Aug 2008 Join Date
    EST , PaldiskiLocation
    311Posts

    Re: About SQL Commands

    Yes .. i want to dipslay the chars Information "Who is online?" (Name , LVL and WorldIDX (Not numbers ) in index.php of Chumpy's Reg page

  6. #6
    The Dinosaur chumpywumpy is offline
    MemberRank
    Jun 2008 Join Date
    /f451/Location
    5,127Posts

    Re: About SQL Commands

    Oh i see, sorry. The map names are not held in the database so you can't do it from a query. You could add a table to the database with the map numbers and then use a join to join the name table onto it but that is the hard way. It would be best to use an array in PHP.

    First make the array of map names:
    Code:
    $maps_array=array(1=>'Bloody Ice',2=>'Desert Scream',3=>'Green Despair');
    You can add the rest of the map names, just follow that format (map number => map name, you can skip numbers like map 11 and 12). Now run your query and get the user's name and map number so you can read the array for the name:

    Code:
    $r=mssql_query("select * from select [name],lev,worldidx from dbo.cabal_character_table where and login=1");
    $row=mssql_fetch_row($r);
    echo 'Name: '.$row[0].'<br />';
    echo 'Level: '.$row[1].'<br />';
    echo 'Map: '.$maps_array[$row[2]].'<br />';
    That will read the maps_array entry for the map number and get the map name.

  7. #7
    Account Upgraded | Title Enabled! maxgo1 is offline
    MemberRank
    Aug 2008 Join Date
    EST , PaldiskiLocation
    311Posts

    Re: About SQL Commands

    Big Thanks ... and what command i should use that (Now online chars : "Mssql Query of Info" ) ?

    ADDED

    And there are your query has error for PHP (If using the chumpy's reg page)
    $r=mssql_query("select * from select [name],lev,worldidx from dbo.cabal_character_table where and login=1");
    Needed:
    $r=mssql_query("select * from select [name],lev,worldidx from '.DB_GAM.'.dbo.cabal_character_table where and login=1");
    i not sure

  8. #8
    The Dinosaur chumpywumpy is offline
    MemberRank
    Jun 2008 Join Date
    /f451/Location
    5,127Posts

    Re: About SQL Commands

    Code:
    $r=mssql_query("select * from select [name],lev,worldidx from ".DB_GAM.".dbo.cabal_character_table where and login=1");
    Yes you will need that (different quotes though). Your original query didn't have it so i left it out too.

    To get the total of online chars use this:

    Code:
    select count(*) from ".DB_GAM.".dbo.cabal_character_table where login=1

  9. #9
    Account Upgraded | Title Enabled! maxgo1 is offline
    MemberRank
    Aug 2008 Join Date
    EST , PaldiskiLocation
    311Posts

    Re: About SQL Commands

    Quote Originally Posted by chumpywumpy View Post
    Oh i see, sorry. The map names are not held in the database so you can't do it from a query. You could add a table to the database with the map numbers and then use a join to join the name table onto it but that is the hard way. It would be best to use an array in PHP.

    First make the array of map names:
    Code:
    $maps_array=array(1=>'Bloody Ice',2=>'Desert Scream',3=>'Green Despair');
    You can add the rest of the map names, just follow that format (map number => map name, you can skip numbers like map 11 and 12). Now run your query and get the user's name and map number so you can read the array for the name:

    Code:
    $r=mssql_query("select * from select [name],lev,worldidx from dbo.cabal_character_table where and login=1");
    $row=mssql_fetch_row($r);
    echo 'Name: '.$row[0].'<br />';
    echo 'Level: '.$row[1].'<br />';
    echo 'Map: '.$maps_array[$row[2]].'<br />';
    That will read the maps_array entry for the map number and get the map name.
    Chumpy in your page if paste this ... it will show only 1 Char info .. how to solve it?

  10. #10
    The Dinosaur chumpywumpy is offline
    MemberRank
    Jun 2008 Join Date
    /f451/Location
    5,127Posts

    Re: About SQL Commands

    Maybe you should check out some of the tutorials at php.net :P

    Code:
    $maps_array=array(1=>'Bloody Ice',2=>'Desert Scream',3=>'Green Despair');
    $r=mssql_query("select * from select [name],lev,worldidx from dbo.cabal_character_table where and login=1");
    for ($i=1;$i<=mssql_num_rows($r);$i++) {
      $row=mssql_fetch_row($r);
      echo 'Name: '.$row[0].'<br />';
      echo 'Level: '.$row[1].'<br />';
      echo 'Map: '.$maps_array[$row[2]].'<br />';	
      mssql_next_result($r);
    }



Advertisement