Jump to content

Barand

Moderators
  • Posts

    24,565
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. The player_points table in my version will enable you to find the winning user this week / this month / this season etc. If, as in the second version, you accumulate the points in the player record then you lose the time element and at some time you have the overhead of having to reset them all to zero (and lose any historical player performance data) The second version's user_team table enables users to have more than one team if that is a requirement.
  2. The matchsort() custom sort function will sort the array by sportname - tournamentname - matchname. $matches = Array ( 0 => Array ( 'sportname' => 'Football', 'tournamentname' => 'Crown League', 'thetime' => 201308021600, 'matchname' => 'Reds vs Whites', 'linkset' => Array ( 'link' => 'link1.html' ) ) , 1 => Array ( 'sportname' => 'Football', 'tournamentname' => 'Prince League', 'thetime' => 201308021130, 'matchname' => 'Blues vs Yellows', 'linkset' => Array ( 'link' => 'link2.html' ) ), 2 => Array ( 'sportname' => 'Football', 'tournamentname' => 'Crown League', 'thetime' => 201308021000, 'matchname' => 'Greys vs Whites', 'linkset' => Array ( 'link' => 'link3.html' ) ) ); usort($matches, 'matchsort'); echo '<pre>',print_r($matches, true),'</pre>'; function matchsort ($a, $b) { $x = strcmp($a['sportname'], $b['sportname']); if ($x==0) { $y = strcmp($a['tournamentname'], $b['tournamentname']); if ($y==0) { return strcmp($a['matchname'], $b['matchname']); } else{ return $y; } } else { return $x; } } OUTPUT Array ( [0] => Array ( [sportname] => Football [tournamentname] => Crown League [thetime] => 201308021000 [matchname] => Greys vs Whites [linkset] => Array ( [link] => link3.html ) ) [1] => Array ( [sportname] => Football [tournamentname] => Crown League [thetime] => 201308021600 [matchname] => Reds vs Whites [linkset] => Array ( [link] => link1.html ) ) [2] => Array ( [sportname] => Football [tournamentname] => Prince League [thetime] => 201308021130 [matchname] => Blues vs Yellows [linkset] => Array ( [link] => link2.html ) ) )
  3. like this [matches] => Array ( [0] => Array ( [sportname] => Football [tournamentname] => Crown League [thetime] => 201308021600 [matchname] => Reds vs Whites [linkset] => Array ( [link] => link1.html ) ) [1] => Array ( [sportname] => Football [tournamentname] => Prince League [thetime] => 201308021130 [matchname] => Blues vs Yellows [linkset] => Array ( [link] => link2.html ) ) [2] => Array ( [sportname] => Football [tournamentname] => Crown League [thetime] => 201308021000 [matchname] => Reds vs Whites [linkset] => Array ( [link] => link3.html ) ) )
  4. First step is to create a consistent array structure. If the data is coming from a database it is probably easier to do it in the query.
  5. MySql does not support FULL OUTER JOIN, however see http://www.it-iss.com/mysql/mysql-full-outer-join/
  6. Do you have problem with posting the xml source?
  7. Store the players' points for each player and not for each member of every user's team. That way you only have to add a record for each player getting points in a match rather than updating all the team records. +-----------+ +-----------+ | user | | player | +-----------+ +-----------+ | u_id |--+ +-| p_id |---+ | username | | | | playername| | +-----------+ | | +-----------+ | | | | | +-------------+ | | +--------------+ | | user_team | | | | player_points| | +-------------+ | | +--------------+ +-<| u_id | | +--<| p_id | | p_id |>--+ | match_date | +-------------+ | points | +--------------+ Then you can the get the total points for each user with a simple query SELECT u.username, SUM(pp.points) as total_points FROM user u INNER JOIN user_team t USING (u_id) LEFT JOIN player_points pp USING (p_id) GROUP BY u.u_id ORDER BY total_points DESC
  8. That's a term I haven't heard for a long time
  9. Post your code. In the code you posted earlier roll is always 20000
  10. All those roll numbers are in class 10 so $percent1 is correct
  11. there should be an error message - you are trying to update cel.NAP_TO, but cel is not defined anywhere
  12. When you run the update query, have you checked for the value in mysqli_error(), or the equivalent in whatever library you are using
  13. You need the word "WHERE" in that query
  14. You have a LEFT JOIN so where there is no matching record (on company_id) in the contact table the fields from that table contain null. Check your data
  15. JOINs are part of the FROM clause and need to come before the WHERE clause
  16. A procedure is merely a function that doesn't return a value (void function)
  17. Can you echo $sql; Then we can see what the query really looks like
  18. syntax is NOW() - INTERVAL 1 DAY
  19. As Muddy said, your data is in need of better organization, but the way you have it now you could SELECT soldby, SUM( CASE WHEN package = 25 THEN 100.00 WHEN package = 6 THEN 25.00 WHEN package = 1 THEN 5.00 END ) as moneyEarned, SUM(package) as ducksSold FROM ( SELECT DISTINCT soldby, email, package FROM yourTableName ) as ducksales
  20. Look at your variables $query = "SELECT * FROM `questions_user` ORDER BY id DESC"; $result = mysql_query($query); if (!mysql_query($value)) { die('Cannot obtain $query!' . mysql_error()); } Change to if (!$result) { die('Cannot obtain $query!' . mysql_error()); }
  21. see http://www.php.net/manual/en/datetime.createfromformat.php and http://www.php.net/manual/en/datetime.format.php
  22. It would depend on what uses you would have for the coordinates. If you need search on coordinates,for example, to match areas with common coordinates to find adjacent areas, then you need to normalize and store in separate rows. If they are purely for drawing polygons then it doesn't really matter. If in doubt, I'd normalize for flexibility.
  23. SELECT COUNT(*) as total FROM `$tablename` WHERE domainstatus = 'Active'
  24. When using JOIN ... ON syntax you need to use table names (or table aliases) as prefixes to the column names when specifying the join ... ON company_id = company_id should be ... ON company.company_id = contact.company_id
  25. An elseif statement will only execute if the preceding if (or elseif) statements are false.
×
×
  • 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.