Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12
  1. #11
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Use a INNER JOIN.

  2. #12
    Join Date
    Mar 2008
    Location
    Swindon, UK
    Posts
    1,274
    Tokens
    187
    Habbo
    :Ltd

    Latest Awards:

    Default

    Quote Originally Posted by Decode View Post
    For a database I have 2 tables setup, they are like-



    I need to order the first table by num (SELECT * FROM `table1` ORDER BY `num` DESC) then I need to match the ID of that to the id in table 2. And it probs needs to be done in 1 mysql query because it needs to be used with mysql_fetch_assoc().

    Sorry if what I've said is confusing. I have tried my best to explain it

    +Rep for any help

    Thanks.
    For table one you should have multi rows so

    ID (Article ID)
    UserID (The users ID, thats it)

    $query = mysql_query( "SELECT * FROM `table1` WHERE `ID` = '213'" );

    $peopleVoted = mysql_num_rows( $query );

    $f = mysql_fetch_array( $query );

    $query_2 = mysql_query( "SELECT * FROM `table2` WHERE `ID` = '" . $f[ 'ID' ] . "' LIMIT 1" );

    $r = mysql_fetch_array( $query_2 );

    I dont really get it but thats how I see it.
    Hi, names James. I am a web developer.

Page 2 of 2 FirstFirst 12

Posting Permissions

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