-
Posts
24,565 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Help with database design - complex relationship
Barand replied to dhirajkumar41's topic in MySQL Help
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. -
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 ) ) )
-
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 ) ) )
-
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.
-
MySql does not support FULL OUTER JOIN, however see http://www.it-iss.com/mysql/mysql-full-outer-join/
-
Do you have problem with posting the xml source?
-
Help with database design - complex relationship
Barand replied to dhirajkumar41's topic in MySQL Help
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 -
Need Help With Loop of Results After Join Query
Barand replied to spock9458's topic in PHP Coding Help
That's a term I haven't heard for a long time -
How Can i Make a Conditon to get two diffrent Percentage
Barand replied to allpkresults's topic in PHP Coding Help
Post your code. In the code you posted earlier roll is always 20000 -
How Can i Make a Conditon to get two diffrent Percentage
Barand replied to allpkresults's topic in PHP Coding Help
All those roll numbers are in class 10 so $percent1 is correct -
there should be an error message - you are trying to update cel.NAP_TO, but cel is not defined anywhere
-
When you run the update query, have you checked for the value in mysqli_error(), or the equivalent in whatever library you are using
-
You need the word "WHERE" in that query
-
Simple INSERT Script Fails - No Error Message
Barand replied to spock9458's topic in PHP Coding Help
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 -
Simple INSERT Script Fails - No Error Message
Barand replied to spock9458's topic in PHP Coding Help
JOINs are part of the FROM clause and need to come before the WHERE clause -
A procedure is merely a function that doesn't return a value (void function)
-
Can you echo $sql; Then we can see what the query really looks like
-
syntax is NOW() - INTERVAL 1 DAY
-
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
-
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()); }
-
see http://www.php.net/manual/en/datetime.createfromformat.php and http://www.php.net/manual/en/datetime.format.php
-
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.
- 7 replies
-
- google maps api
- polygon
-
(and 2 more)
Tagged with:
-
SELECT COUNT(*) as total FROM `$tablename` WHERE domainstatus = 'Active'
-
Simple INSERT Script Fails - No Error Message
Barand replied to spock9458's topic in PHP Coding Help
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 -
An elseif statement will only execute if the preceding if (or elseif) statements are false.