Closed Thread
Results 1 to 3 of 3

Thread: MySQL Multiple queries

  1. #1
    Copephobia is offline Newbie
    Join Date
    Sep 2009
    Posts
    1
    Rep Power
    0

    MySQL Multiple queries

    I am currently coding a multiplayer game in php and I am lost on one part.
    On the rankings page, I have the table display the following:

    Rank - Username - Alliance - etc.
    01 - Copephobia - 1 - etc.
    02 - Bob - 2 - etc.

    What I want to do is write the alliance tag for each alliance the member is in.

    Here's how it goes:
    -Sort player id's based on rank
    -Display player information

    Here's what I want to do next:
    -print alliance tag based on alliance id



    how exactly what I do that?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: MySQL Multiple queries

    I'm not sure exactly what you are asking for. The code below is what my interpretation of what you wanted is. If this isn't what you want it would be beneficial if you elaborate on what you want.

    Code:
    $rankingQuery "Select * from users ORDER BY rank Asc, username";
    $runRankingQuery mysql_query($rankingQuery)or die(mysql_error());
    while(
    $getRank mysql_fetch_array($runRankingQuery))
    {
    echo 
    "User:";
    echo 
    $getRank['username'];
    echo 
    "<br />Rank:";
    echo 
    $getRank['rank'];
    echo 
    "<br />Aliance:";

    $alianceQuery="Select alianceName from aliance where alianceId = $getRank[aliance]";
    $runAlianceQuery=mysql_query($alianceQuery)or die(mysql_error());
    $getAliance=mysql_fetch_array($runAlianceQuery);

    echo 
    $getAliance['alianceName'];
    echo 
    "<br /><br />";

    Edit: Re read your post. Code has been updated.

  4. #3
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: MySQL Multiple queries

    It could also be useful to use a join to get the alliance name as part of the original query.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Combining multiple rows to one row in MySQL
    By Metalhead in forum Database & Database Programming
    Replies: 1
    Last Post: 01-22-2011, 03:28 AM
  2. Multiple Condition MySql Query
    By Furry Pancake in forum PHP Development
    Replies: 5
    Last Post: 10-05-2010, 12:23 PM
  3. Nested MySQL Queries in PHP
    By matrob in forum PHP Development
    Replies: 1
    Last Post: 10-05-2010, 11:52 AM
  4. multiple mysql servers on windows
    By itay in forum Database & Database Programming
    Replies: 5
    Last Post: 07-05-2010, 03:48 PM
  5. SESSION variables or MYSQL queries
    By Demodog in forum PHP Development
    Replies: 3
    Last Post: 04-15-2010, 03:44 AM

Tags for this Thread

Bookmarks

Posting Permissions

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