Jump to content

PHP12345

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

PHP12345's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, Thanks for that, The code you suggested is giving an error message... [i]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*,COUNT(`fixtures_results.id`) AS "fixtures_results.motm" FROM `users`,`fixtures' at line 1[/i] The webhost is currently running MySQL 4.1.11 (not sure if that makes a difference).
  2. Is there anyone who can help? I'm struggling with my temporary tables  :'( I'm quite happy to pay someone who helps me.
  3. Each match has a MoTM so the database is querying how many times the Member ID is listed as the MoTM (2 queries because the league & cup are logged in different tables) [code]$motm1_query = mysql_query("SELECT id, clan1, clan2, date FROM fixtures_results WHERE(motm1='".$member['id']."' or motm2='".$member['id']."') ORDER BY date DESC, id DESC"); $motm2_query = mysql_query("SELECT id, clan1, clan2, date FROM cup_results WHERE(motm1='".$member['id']."' or motm2='".$member['id']."') ORDER BY date DESC, id DESC");[/code] Then the MoTM is the total of both queries. This just generates a number. [code]$motm = mysql_num_rows($motm1_query) + mysql_num_rows($motm2_query);[/code] At the moment my script lists the Players (alphabetical order) then lists the no. of MoTM awards next to the Player name. I want the MoTM awards to be listed in order (descending order) with the player name next to it. I've stripped a bit of the code out to make it easier on the eye.. [code]<table width="100%"> <tr> <td colspan="2" class="dark"><div align="center"><b>Players</b></div></td> </tr> <tr> <td class="dark"><b>Username</b></td> <td class="dark"><div align="center"><b>MoTM</b></div></td> </tr> <?php $member_query = mysql_query("SELECT * FROM users WHERE(accept='1') ORDER BY id ASC"); while($member = mysql_fetch_array($member_query)) { if(get_magic_quotes_runtime()) { $member['username'] = stripslashes($member['username']); } $motm1_query = mysql_query("SELECT id, clan1, clan2, date FROM fixtures_results WHERE(motm1='".$member['id']."' or motm2='".$member['id']."')"); $motm2_query = mysql_query("SELECT id, clan1, clan2, date FROM cup_results WHERE(motm1='".$member['id']."' or motm2='".$member['id']."')"); $motm = mysql_num_rows($motm1_query) + mysql_num_rows($motm2_query); ?> <tr> <td class="light"><a href="user_view.php?u=<?php echo $member['id']; ?>"><?php echo $member['username']; ?></a></td> <td class="light"><div align="center"><?php echo $motm; ?></div></td> </tr> <?php } ?> </table>[/code]
  4. Hi, Each player gets 1 row and the MoTM awards are totalled for that player in the second column)
  5. If anyone can help I'll deposit some money to your PayPal account  ;D I've spent ages trying to sort it out but I seem to get into a bigger mess!!!
  6. Can anyone help a PHP n00b  ??? Thanks in advance  ;)
  7. Hi, Thanks, that worked ;D -- I'm trying to do something similar to another script but I can't seem to get it right  :'( This is the original script where it lists all the Players then queries the database to see how many MoTM (man of the match awards) for each player, and puts the number in a column next to the players name. [code]<table width="100%"> <tr> <td colspan="2" class="dark"><div align="center"><b>Players</b></div></td> </tr> <tr> <td class="dark"><b>Username</b></td> <td class="dark"><div align="center"><b>MoTM</b></div></td> </tr> <?php $member_query = mysql_query("SELECT * FROM users WHERE(accept='1') ORDER BY id ASC"); while($member = mysql_fetch_array($member_query)) { if(get_magic_quotes_runtime()) { $member['username'] = stripslashes($member['username']); } $motm1_query = mysql_query("SELECT id, clan1, clan2, date FROM fixtures_results WHERE(motm1='".$member['id']."' or motm2='".$member['id']."') ORDER BY date DESC, id DESC"); $motm2_query = mysql_query("SELECT id, clan1, clan2, date FROM cup_results WHERE(motm1='".$member['id']."' or motm2='".$member['id']."') ORDER BY date DESC, id DESC"); if(mysql_num_rows($motm1_query) > 0 or mysql_num_rows($motm2_query) > 0) { $test1_motm['date'] = 0; $test2_motm['date'] = 0; $test1_motm_query = mysql_query("SELECT date FROM fixtures_results WHERE(motm1='".$member['id']."' or motm2='".$member['id']."') ORDER BY date DESC, id DESC LIMIT 1"); $test2_motm_query = mysql_query("SELECT date FROM cup_results WHERE(motm1='".$member['id']."' or motm2='".$member['id']."') ORDER BY date DESC, id DESC LIMIT 1"); if(mysql_num_rows($test1_motm_query) == 1) { $test1_motm = mysql_fetch_array($test1_motm_query); } if(mysql_num_rows($test2_motm_query) == 1) { $test2_motm = mysql_fetch_array($test2_motm_query); } if($test1_motm['date'] >= $test2_motm['date']) { $motm = mysql_fetch_array($motm1_query); $page_name = 'clan'; } if($test1_motm['date'] < $test2_motm['date']) { $motm = mysql_fetch_array($motm2_query); $page_name = 'cup'; } } $motm = mysql_num_rows($motm1_query) + mysql_num_rows($motm2_query); ?> <tr> <td class="light"><a href="user_view.php?u=<?php echo $member['id']; ?>"><?php echo $member['username']; ?></a></td> <td class="light"><div align="center"><?php echo $motm; ?></div></td> </tr> <?php } ?> </table>[/code] Is there a simple bit of code that I could add so that the list is in order depending on how many MoTM awards the player gets (with the most MoTM awards at the top)? At the moment it lists it according to the Player ID Can this be limited to top 10? Thanks again in advance.
  8. Hello, I have a database with users and their location (City) and want to sort the data depending on the most popular location. I know how to do the basic order ...ORDER BY location DESC... but I don't know how to order by the most popular location i.e. London (35), Bristol (24), Birmingham (15), Cardiff (10)... The only way I know would list London 35 times, Bristol 24 times etc... but I only want the name to appear once with the most popular location first. I also want to limit the output to the top 10, is there a tutorial on how to do this? Sorry for so many questions. Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.