dezkit Posted October 18, 2009 Share Posted October 18, 2009 Hi guys, I have this code, that grabs all the data from a table and echos it, but i have this one separate table for Jailbreak. how can I grab the data from quickgam_jbamxbans for jailbreak only, thank you so much. here is my code: <table border=0 CELLPADDING=4> <tr> <td align=right>Alias</td> <td align=center><a href="http://xxxx/forumdisplay.php?f=2">Dust2Pub</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=3">Deathmatch</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=4">Deathrun</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=55">Jailbreak</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=5">KZ/Bhop</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=8">Freezetag</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=6">ZPlague</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=7">ZRevolution</a></td> </tr> <?php mysql_connect("localhost", "quickgam_me", "xxxx") or die(mysql_error()); mysql_select_db("quickgam_amx") or die(mysql_error()); $query = " SELECT admin_id, server_id, nickname, hostname, access, ashow, admintype FROM amx_amxadmins a, amx_serverinfo s, amx_admins_servers c WHERE c.admin_id = a.id AND c.server_id = s.id AND a.id = c.admin_id AND a.admintype = a.admintype AND a.ashow = a.ashow ORDER BY a.admintype DESC, a.nickname ASC"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $nicks[$row['nickname']][]=$row['server_id']; $admin[$row['nickname']]=$row['admintype']; } $color="1"; foreach($nicks as $nickname=>$serverids) { if($color==1){ $hello = implode(" ",$serverids); echo "<tr bgcolor='#FFF9A1'><td align=right><b>".$nickname."</b><br>"; if($admin[$nickname]=="3"){ echo "<i>Owner</i>"; }elseif($admin[$nickname]=="2"){ echo "<i>Head Admin</i>"; }elseif($admin[$nickname]=="1"){ echo "<i>Admin</i>"; }elseif($admin[$nickname]=="0"){ echo "<i>Co-Owner</i>"; } echo "</td>"; if(strstr($hello,"4")){ // d2pub echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"6")){ // deathmatch echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"1")){ // deathrun echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"8")){ // jailbreak echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"17")){ // kz/bhop echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"2")){ // simpsons echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"14")){ // plague echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"5")){ // rev echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } $color="2"; } else { $hello = implode(" ",$serverids); echo "<tr bgcolor=''><td align=right><b>".$nickname."</b><br>"; if($admin[$nickname]=="3"){ echo "<i>Owner</i>"; }elseif($admin[$nickname]=="2"){ echo "<i>Head Admin</i>"; }elseif($admin[$nickname]=="1"){ echo "<i>Admin</i>"; }elseif($admin[$nickname]=="0"){ echo "<i>Co-Owner</i>"; } echo "</td>"; if(strstr($hello,"4")){ // d2pub echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"6")){ // deathmatch echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"1")){ // deathrun echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"8")){ // jailbreak echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"17")){ // kz/bhop echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"2")){ // simpsons echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"14")){ // plague echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } if(strstr($hello,"5")){ // rev echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } $color="1"; } } ?> </tr> <tr> <td align=right>Alias</td> <td align=center><a href="http://xxxx/forumdisplay.php?f=2">Dust2Pub</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=3">Deathmatch</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=4">Deathrun</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=55">Jailbreak</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=5">KZ/Bhop</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=8">Freezetag</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=6">ZPlague</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=7">ZRevolution</a></td> </tr> </table> please help me out, thank you for anything posted Quote Link to comment Share on other sites More sharing options...
dreamwest Posted October 18, 2009 Share Posted October 18, 2009 You can cut down half your code like this if(strstr($hello,"4") || strstr($hello,"1") etc....){ // d2pub echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } You just repeating the same code...Remember : less code = Happiness You almost have correct code for a join , Im assuming these are seperate tables: FROM amx_amxadmins as a, amx_serverinfo as s, amx_admins_servers as c Quote Link to comment Share on other sites More sharing options...
dezkit Posted October 18, 2009 Author Share Posted October 18, 2009 oops, i forgot, quickgam_jbamxbans is another database, not another table, sorry Quote Link to comment Share on other sites More sharing options...
dreamwest Posted October 18, 2009 Share Posted October 18, 2009 Youll need a second connection: $con1 = mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("dbname", $con1) or die(mysql_error()); $con2 = mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("dbname", $con2) or die(mysql_error()); $result = mysql_query ("SELECT * from table ", $con1) or die(mysql_error()); $num = mysql_num_rows( $result ); //etc etc.... Quote Link to comment Share on other sites More sharing options...
dezkit Posted October 18, 2009 Author Share Posted October 18, 2009 can you implement it in my code, i can't seem to figure it out, thank you Quote Link to comment Share on other sites More sharing options...
dreamwest Posted October 18, 2009 Share Posted October 18, 2009 Actually its similar to connecting normally the loops are the same <table border=0 CELLPADDING=4> <tr> <td align=right>Alias</td> <td align=center><a href="http://xxxx/forumdisplay.php?f=2">Dust2Pub</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=3">Deathmatch</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=4">Deathrun</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=55">Jailbreak</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=5">KZ/Bhop</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=8">Freezetag</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=6">ZPlague</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=7">ZRevolution</a></td> </tr> <?php $con1 = mysql_connect("localhost", "quickgam_me", "xxxx") or die(mysql_error()); mysql_select_db("quickgam_amx", $con1) or die(mysql_error()); $con2 = mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("jailbreak", $con2) or die(mysql_error()); $result = mysql_query ("SELECT * from table ", $con1) or die(mysql_error()); $result2 = mysql_query ("SELECT * from quickgam_jbamxbans", $con2) or die(mysql_error()); //////////////////////// //Now pull anything you want out of $result2 //////////////////////// $num = mysql_num_rows( $result ); $query = " SELECT admin_id, server_id, nickname, hostname, access, ashow, admintype FROM amx_amxadmins a, amx_serverinfo s, amx_admins_servers c WHERE c.admin_id = a.id AND c.server_id = s.id AND a.id = c.admin_id AND a.admintype = a.admintype AND a.ashow = a.ashow ORDER BY a.admintype DESC, a.nickname ASC"; $result = mysql_query($query, $con1) or die("CASE 1"); while($row = mysql_fetch_array($result)){ $nicks[$row['nickname']][]=$row['server_id']; $admin[$row['nickname']]=$row['admintype']; } $color="1"; foreach($nicks as $nickname=>$serverids) { if($color==1){ $hello = implode(" ",$serverids); echo "<tr bgcolor='#FFF9A1'><td align=right><b>".$nickname."</b><br>"; if($admin[$nickname]=="3"){ echo "<i>Owner</i>"; }elseif($admin[$nickname]=="2"){ echo "<i>Head Admin</i>"; }elseif($admin[$nickname]=="1"){ echo "<i>Admin</i>"; }elseif($admin[$nickname]=="0"){ echo "<i>Co-Owner</i>"; } echo "</td>"; if(strstr($hello,"4") || strstr($hello,"6") || strstr($hello,"1") || strstr($hello,"8") || strstr($hello,"17") || strstr($hello,"2") || strstr($hello,"14") || strstr($hello,"5")){ // d2pub echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } $color="2"; } else { $hello = implode(" ",$serverids); echo "<tr bgcolor=''><td align=right><b>".$nickname."</b><br>"; if($admin[$nickname]=="3"){ echo "<i>Owner</i>"; }elseif($admin[$nickname]=="2"){ echo "<i>Head Admin</i>"; }elseif($admin[$nickname]=="1"){ echo "<i>Admin</i>"; }elseif($admin[$nickname]=="0"){ echo "<i>Co-Owner</i>"; } echo "</td>"; if(strstr($hello,"4") || strstr($hello,"6") || strstr($hello,"1") || strstr($hello,"8") || strstr($hello,"17") || strstr($hello,"2") || strstr($hello,"14") || strstr($hello,"5")){ echo "<td><center><img src='http://xxxx/yes.gif' alt=''></center></td>"; } else { echo "<td><center><img src='http://xxxx/no.gif' alt=''></center></td>"; } $color="1"; } } ?> </tr> <tr> <td align=right>Alias</td> <td align=center><a href="http://xxxx/forumdisplay.php?f=2">Dust2Pub</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=3">Deathmatch</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=4">Deathrun</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=55">Jailbreak</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=5">KZ/Bhop</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=8">Freezetag</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=6">ZPlague</a></td> <td align=center><a href="http://xxxx/forumdisplay.php?f=7">ZRevolution</a></td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
dezkit Posted October 18, 2009 Author Share Posted October 18, 2009 doesn't work databases: quickgam_amx and quickgam_jbamxbans Quote Link to comment Share on other sites More sharing options...
dezkit Posted October 23, 2009 Author Share Posted October 23, 2009 Bump Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.