Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
[PHP] Help Grabbing From 2 tables [MySql]
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="JayC" data-source="post: 359016" data-attributes="member: 36373"><p>I tried to use a join statement, but I had a rough time because trying to get the specific user and then all that, so I was just going to use 2 queries in a while loop.</p><p>[PHP]</p><p></p><p>$q = mysql_query("SELECT * FROM users WHERE groupid = '" . $job['id'] . "' ORDER BY jobrank DESC") or die();</p><p> while($user = mysql_fetch_assoc($q))</p><p> {</p><p> echo "<table width='100%'>";</p><p> echo "<tr><td width='0%'>";</p><p> </p><p> </p><p> echo "<img src='" . FigGen() . $user['figure'] . "'>";</p><p> $query2 = mysql_query("SELECT groupid,jobrank FROM users WHERE username = '".$user['username']."'");</p><p> $query3 = mysql_query("SELECT name FROM jobranks WHERE jobrank = '".$query2['groupid']."' AND rankid = '".$query2['jobrank']."'");</p><p> echo "</p><p> </p><p> </td></p><p> <td></p><p> <b>Name:</b> " . $user['username'] . " <br/></p><p> <b>Rank:</b> " . $query3['name'] . " <br/></p><p> <b>Last visit:</b> " . date("F j, Y, g:i a",$user['timestamp_lastvisit']) . "</p><p> </td></p><p> </tr>";</p><p> </p><p> echo "</table><hr>";</p><p> }</p><p>[/PHP]</p><p>This is what the page looks like:</p><p><img src="http://i.imgur.com/5bvmd5c.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /> </p><p>So I can't seem to get it to display the rank. </p><p></p><p>Users Table -> Groupid, jobrank</p><p>Jobranks Table -> Jobid, rankid</p></blockquote><p></p>
[QUOTE="JayC, post: 359016, member: 36373"] I tried to use a join statement, but I had a rough time because trying to get the specific user and then all that, so I was just going to use 2 queries in a while loop. [PHP] $q = mysql_query("SELECT * FROM users WHERE groupid = '" . $job['id'] . "' ORDER BY jobrank DESC") or die(); while($user = mysql_fetch_assoc($q)) { echo "<table width='100%'>"; echo "<tr><td width='0%'>"; echo "<img src='" . FigGen() . $user['figure'] . "'>"; $query2 = mysql_query("SELECT groupid,jobrank FROM users WHERE username = '".$user['username']."'"); $query3 = mysql_query("SELECT name FROM jobranks WHERE jobrank = '".$query2['groupid']."' AND rankid = '".$query2['jobrank']."'"); echo " </td> <td> <b>Name:</b> " . $user['username'] . " <br/> <b>Rank:</b> " . $query3['name'] . " <br/> <b>Last visit:</b> " . date("F j, Y, g:i a",$user['timestamp_lastvisit']) . " </td> </tr>"; echo "</table><hr>"; } [/PHP] This is what the page looks like: [IMG]http://i.imgur.com/5bvmd5c.png[/IMG] So I can't seem to get it to display the rank. Users Table -> Groupid, jobrank Jobranks Table -> Jobid, rankid [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
[PHP] Help Grabbing From 2 tables [MySql]
Top