buladex Posted July 15, 2010 Share Posted July 15, 2010 on site page i made this : Rank Name Wons Lost 1. Alexutzu 0047 2. test145[PM] 0001 script for that is: <tr> <td width="*" align="center">Rank</td> <td width="*" align="center"><font color="#000000">Name</td> <td width="*" align="center"><font color="#000000">Wons</td> <td width="*" align="center"><font color="#000000">Lost</td> </tr> <?php $rank = mysql_query('SELECT player_name,data FROM xxxx WHERE event_type= 971' .' ORDER by data desc LIMIT '.$limit.';'); $i=1; while ($row = mysql_fetch_array($rank)) { echo '<tr><td align="center">'.$i.'.</td> <td align="center"><font color="#0000FF">'.$row['player_name'].'</td> <td align="center"><font color="#FF0080">'.$row['data'].'</td> [u]HERE i need lost table which is same as win only event_type= 972 how i do that??[/u] </tr> '; $i++; } so i need lost table!!! Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/ Share on other sites More sharing options...
Mchl Posted July 15, 2010 Share Posted July 15, 2010 SELECT w.player_name,w.data AS won, l.data AS lost FROM xxxx AS w CROSS JOIN xxxx AS l USING (player_name) WHERE w.event_type= 971 AND l.event_type = 972 Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086373 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 is that to replace rank sql select? Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086375 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 not working so far , i replaced it and i get error at : while ($row = mysql_fetch_array($rank)) { in: <?php $rank = mysql_query('SELECT w.player_name,w.data AS won, l.data AS lost FROM cq_statistic AS w CROSS JOIN cq_statistic AS l USING (player_name) WHERE w.event_type= 971 AND l.event_type = 972' .' ORDER by data desc LIMIT '.$limit.';'); $i=1; while ($row = mysql_fetch_array($rank)) { echo '<tr><td align="center">'.$i.'.</td> <td align="center"><font color="#0000FF">'.$row['player_name'].'</td> <td align="center"><font color="#FF0080">'.$row['data'].'</td> </tr> '; $i++; } Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086378 Share on other sites More sharing options...
fenway Posted July 15, 2010 Share Posted July 15, 2010 What error? Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086425 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 error on this line : while ($row = mysql_fetch_array($rank)) { i think now it cant be ORDER by data cuz both win and lose are data Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086427 Share on other sites More sharing options...
Mchl Posted July 15, 2010 Share Posted July 15, 2010 Indeed you think correct. It needs to be ORDER BY w.data or ORDER BY l.data See this tutorial: http://www.phpfreaks.com/tutorial/debugging-a-beginners-guide/page1 for hints on how to get useful error messages from MySQL Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086447 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 acctualy right is w.data but still not working, got no error but doesnt show won and lost points: <?php $rank = mysql_query('SELECT w.player_name,w.data AS Won, l.data AS Lost FROM xxxx AS w CROSS JOIN xxxx AS l USING (player_name) WHERE w.event_type= 971 AND l.event_type = 972' .' ORDER BY w.data desc LIMIT '.$limit.';'); $i=1; while ($row = mysql_fetch_array($rank)) { echo '<tr><td align="center">'.$i.'.</td> <td align="center"><font color="#0000FF">'.$row['player_name'].'</td> <td align="center"><font color="#FF0080">'.$row['data'].'</td> </tr> '; $i++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086458 Share on other sites More sharing options...
Mchl Posted July 15, 2010 Share Posted July 15, 2010 Because you're not displaying those. <td align="center"><font color="#FF0080">'.$row['Won'].'</td> <td align="center"><font color="#FF0080">'.$row['Lost'].'</td> Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086462 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 i am all script: <div align="center"><font color="#FF0000", size="5px"><b> Top Arena</b></div> <table<?php echo $tableSet; ?>> <tr> <td width="*" align="center">Rank</td> <td width="*" align="center"><font color="#000000">Name</td> <td width="*" align="center"><font color="#000000">Won</td> <td width="*" align="center"><font color="#000000">Lost</td> </tr> <?php $rank = mysql_query('SELECT w.player_name,w.data AS Won, l.data AS Lost FROM xxxx AS w CROSS JOIN xxxx AS l USING (player_name) WHERE w.event_type= 971 AND l.event_type = 972' .' ORDER BY w.data desc LIMIT '.$limit.';'); $i=1; while ($row = mysql_fetch_array($rank)) { echo '<tr><td align="center">'.$i.'.</td> <td align="center"><font color="#0000FF">'.$row['player_name'].'</td> <td align="center"><font color="#FF0080">'.$row['data'].'</td> <td align="center"><font color="#FF0080">'.$row['Won'].'</td> <td align="center"><font color="#FF0080">'.$row['Lost'].'</td> </tr> '; $i++; } ?> </tbody></table></td> Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086464 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 yes u right i found 1 bug ty ill reply whit result Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086466 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 my old script shows this whit 'won' table only which is corect: Rank Name Won 1. SPIU[PM] 0003 2. ~*CaTHLeeN*~ 0001 whit new script shows : Rank Name Won Lost 1. ~*CaTHLeeN*~ 0001 0001 which is corect by points but where is real rank 1 player???????? Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086467 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 yes!!! i know why cuz SPIU[PM]has 0 lost!!! so how i do to show 0 on lost??? cuz far as i see script aint gone show if u have 0 lost Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086471 Share on other sites More sharing options...
Mchl Posted July 15, 2010 Share Posted July 15, 2010 Ok, so let's do it so it will display when the player has no wins too: SELECT p.player_name, IFNULL(w.data,0) AS won, IFNULL(l.data,0) AS lost FROM ( SELECT DISTINCT player_name FROM xxxx WHERE event_type IN (971,972) ) AS p LEFT JOIN ( SELECT player_name, data FROM xxxx WHERE event_type = 971 ) AS w USING (player_name) LEFT JOIN ( SELECT player_name, data FROM xxxx WHERE event_type = 972 ) AS l USING (player_name) Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086480 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 not working pfff and i see in script u put won whit 0 also that aint needed this rank depends on won so it cant be 0 but far as we made the script if the player has wins but lost = 0 wont show him in rank Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086487 Share on other sites More sharing options...
Mchl Posted July 15, 2010 Share Posted July 15, 2010 Use mysql_error to check if something's wrong with tje query $rank = mysql_query('SELECT ...') or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086500 Share on other sites More sharing options...
buladex Posted July 15, 2010 Author Share Posted July 15, 2010 hehe found a simple and easy solution ty for all ur help +1 k from me Quote Link to comment https://forums.phpfreaks.com/topic/207822-need-help-to-finish-this/#findComment-1086511 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.