Jump to content

Zepo.

Members
  • Posts

    306
  • Joined

  • Last visited

    Never

About Zepo.

  • Birthday 09/07/1992

Contact Methods

  • AIM
    sL+Zepo
  • Website URL
    http://www.completeladders.com

Profile Information

  • Gender
    Male
  • Location
    California

Zepo.'s Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. This is a little confusing so please bear with me. I was thinking of using left.join but couldn't figure out how to implement it properly. I am trying to order all of the results from a table names 'clans' based on how many points the clan has. To calculate the points you have to go into another table 'clanteams' and then loop every team in the clan pulling wins and losses from a row in a specific ladder table. Here is the code i have to calculate the points. $total[wins] = 0; $total[loss] = 0; $members=mysql_query("SELECT id,clanid,teamid,DATE_FORMAT(datejoined,'%M %d, %Y') FROM clanteams WHERE clanid='$member[id]'"); while(list($id,$clanid,$teamid,$joined)=mysql_fetch_row($members)){ $team=mysql_query("SELECT name,ladderid FROM teams WHERE id='$teamid'"); if(mysql_num_rows($team) == 0) continue; $team=mysql_fetch_array($team); $ladder=mysql_query("SELECT name FROM ladders WHERE id='$team[ladderid]'"); $ladder=mysql_fetch_array($ladder); $linfo=mysql_query("SELECT rank,wins,loss FROM ladder_$team[ladderid] WHERE teamid='$teamid'"); $linfo=mysql_fetch_array($linfo); $total[wins] = $total[wins] + $linfo[wins]; $total[loss] = $total[loss] + $linfo[loss]; } $totalpoints = ($total[wins] * 2) - $total[loss]; So now i want to loop through every row in the clans table, and using the above code oder them by $total points. Ive spent hours wrapping my head around it and still cannot figure it out. Please help.
  2. Yes i think i can work with that thank you so much.
  3. Yes but its inserting the two first rows in two other rows when it should insert the first two rows into one row. Here a picture i made
  4. Thank you professor badass, were almost there but it should look similar to this, i know it doesnt work but maybe youll get the idea. <?php $query1 = "SELECT * FROM example1 LIMIT 0, 2"; $result1 = mysql_query($query1) or die(mysql_error()); while($row1 = mysql_fetch_array($result1)){ $query2 = "INSERT INTO example2 (id, name, id2, name2) VALUES('".$row1["id"]."', '".$row1["name"].",".$row2["id"].","$row2["name"]"' ) "; $result2 = mysql_query($query2) or die(mysql_error()); $query3 = "DELETE FROM example1 WHERE id='".$row1["id"]."'"; $query3 = "DELETE FROM example1 WHERE id='".$row2["id"]."'"; $result3 = mysql_query($query3) or die(mysql_error()); } ?>
  5. Anyone please? This seems so easy its just i cant get it to insert without inserting two rows.
  6. Took a break but still have this problem, the two matched rows are random where leagueid=whateever So when a league is started it will go throught and randomly insert into the table from two of the players then delete.........
  7. Pull two rows from same table that have ID and Name. Create a row in different table with both ids and names from first two. Delete the original two rows Make sense?
  8. I thought JOIN was for two different tables....
  9. Heres what I have so far //Start any leagues $leagues=mysql_query("SELECT id,ladder,datestart,hourstart FROM leagues"); while(list($id,$ladderid,$datestart,$hourstart)=mysql_fetch_row($leagues)){ $timenow = date('N', time()); $timenow2 = date('H',time()); if($timenow == $datestart && $timenow2 == $hourstart){ $updatel = mysql_query("SELECT * FROM leagueplayers WHERE league='$id'"); $update2 = mysql_query("SELECT * FROM leagueplayers WHERE league='$id'"); while ($player1 = mysql_fetch_array($updatel) && $player2 = mysql_fetch_array($update2)) { $totalcountleag=mysql_query("SELECT COUNT(*) FROM leagueplayers WHERE league='$id'"); $totalcountleag=mysql_fetch_array($totalcountleag); $totalcountleag="$totalcountleag[0]"; if($totalcountleag >= 2){ $playerd=mysql_query("SELECT * FROM teams WHERE id='$player1[team]'"); $playerd=mysql_fetch_array($playerd); $player2d=mysql_query("SELECT * FROM teams WHERE id='$player2[team]'"); $player2d=mysql_fetch_array($player2d); mysql_query("INSERT INTO challenges (ladderid, challgrid, challgdid, challgrname, challgdname, matchfinder) VALUES ( '$ladderid','{$player1['team']}','{$player2['team']}','{$playerd['name']}','{$player2d['name']}','1')"); // $challenge_id=mysql_query("SELECT challid FROM challenges WHERE challgrname='$playerd[name]' AND challgdname='$player2d[name]'"); // $challenge_id=mysql_fetch_array($challenge_id); // mysql_query("INSERT INTO chall_chat (chall_id,challenger,challenged,type) // VALUES('$challenge_id[challid]','$player1[team]','$player2[team]','1')"); // mysql_query("DELETE FROM leagueplayers WHERE id='$player1[id]'"); //mysql_query("DELETE FROM leagueplayers WHERE id='$player2[id]'"); } } } } But the problem is it creates two rows in challenges when it should only create one. The zero on the first one should be the 405 and the first blank should be Gravy Boat and the second row shouldnt exist.... 12107 54 0 407 (Blank) bling bling 2010-07-15 04:14:25 1 12108 54 0 405 (Blank) Gravy Boat 2010-07-15 04:14:25 1
  10. So player1 doesnt pull any info here: if($timenow1 == $timenow5 && $timenow2 >= $timenow6){ mysql_query("UPDATE leagues SET status='0' WHERE id='$id'"); $update = mysql_query("SELECT * FROM leagueplayers WHERE league='$id'"); while ($player1 = mysql_fetch_array($update) && $player2 = mysql_fetch_array($update)) { echo $player1[id]; echo"-"; echo $player2[id]; } }
  11. Insert another row with data from two rows, of the loop. What I posted almost works and is what I want but the first row doesnt seem to be working while the second row does. Its been a while since I've used PHP so i'm a bit rusty sorry
  12. No, the first update was working fine, player1[id] just wasnt displaying 4 like it should have.
  13. hmm so I have this: if($timenow1 == $timenow5 && $timenow2 >= $timenow6){ mysql_query("UPDATE leagues SET status='0' WHERE id='$id'"); $update = mysql_query("SELECT * FROM leagueplayers WHERE league='$id'"); while ($player1 = mysql_fetch_array($update) && $player2 = mysql_fetch_array($update)) { echo $player1[id]; echo"-"; echo $player2[id]; } } And i got -5, the first ones not pulling anything...hmm
×
×
  • 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.