Skipjackrick
Members-
Posts
196 -
Joined
-
Last visited
Never
About Skipjackrick
- Birthday 02/10/1981
Contact Methods
-
AIM
Skipjack+GCR
Profile Information
-
Gender
Male
-
Location
San Antonio, TX
Skipjackrick's Achievements
Regular Member (3/5)
0
Reputation
-
Thank you....That's defnitely an easy fix you've got there. However, Wouldn't storing the IP fill up my database with a ton of information? Is there a better way to handle that?
-
I am trying to find some example code where the user could click a button to approve or disapprove a certain topic. Or even like a voting type of code where they vote yes or no. The database would just update a running count each time the user clicked on the approve or disapprove buttons. I'll also need each user to only be allowed to vote once on a particular topic. Any ideas for some examples somewhere? Seems like I could write something like <?php //topic variable passed through a link I assume $topic = 2343; //user clicks on approve $approve = "UPDATE topic SET a_count = a_count + 1 WHERE topic_id = $topic"; //user clicks on disapprove $disapprove = "UPDATE topic SET d_count = d_count + 1 WHERE topic_id = $topic"; //The rest I am unsure of how to control the user from clicking approve 500 times. Maybe in a $_SESSION? ?>
-
OH!!! I get it...My WHERE statement should also be in the right table. I hope that works.
-
Right table? I am only using one table named Submit.
-
Thanks.. So I've rearranged it a little bit...It seems to work but its only returning 7 rows. When there should be like 15 rows because there are more species than that. Do you happen to know why it might be doing that? <?php //Query for records region 1 $records1 = "SELECT angler ,team_id ,dt.species_id ,length ,image FROM submit join (SELECT species_id ,max(length) as mlength FROM submit GROUP BY species_id ) dt ON (submit.species_id,submit.length) = (dt.species_id,dt.mlength) WHERE submit.region_id = 1 ORDER BY submit.species_id "; $records_result1 = mysql_query($records1) or die(mysql_error()); ?>
-
I am trying to get the largest fish that each angler caught but also associate the correct data in the row. With the following code I get an error message column 'angler' is ambiguous Do you know how to fix that? I am still learning this join and on stuff. select angler, team_id, species_id, length, image from submit join (select angler, max(length) as mlength from submit group by angler) dt on (submit.angler,submit.length) = (dt.angler,dt.mlength) where submit.region_id = 1 order by submit.species_id
-
I know we were just discussing this on this other topic... http://www.phpfreaks.com/forums/mysql-help/find-the-largest-value-for-each-group-and-sum/ And it worked beautifully.... But now I want to group those results by the team that each angler is on.... Or SUM those results and group them by team... Is that possible? For example, the following code outputs....... <?php //connect to the db include 'db_connect.php'; //Testing for total inches $total_inches = "SELECT angler, team_id, SUM(mlength) FROM ( SELECT angler, yyyy, team_id, MAX(length) AS mlength FROM submit WHERE yyyy=2010 GROUP BY angler, species_id ) AS zz GROUP BY angler ORDER BY SUM(mlength) DESC "; $total_inches_result = mysql_query($total_inches) or die(mysql_error()); $RowCount = mysql_num_rows($total_inches_result); ?>
-
Find the largest value for each group and sum
Skipjackrick replied to Skipjackrick's topic in MySQL Help
Has this issue been resolved? Yeah, I mostly got it figured out..... I like your avatar....you must be a male? LOL.... I work as a pharmaceutical scientist during the day. -
Find the largest value for each group and sum
Skipjackrick replied to Skipjackrick's topic in MySQL Help
THANKS SO MUCH!!!! This is exactly what I needed.....now I am just working through customizing it for me.... -
Find the largest value for each group and sum
Skipjackrick replied to Skipjackrick's topic in MySQL Help
AHA!! I need to use SUM(mlength) -
Find the largest value for each group and sum
Skipjackrick replied to Skipjackrick's topic in MySQL Help
This actually got results...but how do I display them using php? It returned 342 rows.. <?php //connect to the db include 'db_connect.php'; //Testing for total inches $total_inches = "SELECT angler, SUM(mlength) FROM ( SELECT angler, MAX(length) AS mlength FROM submit GROUP BY angler, species_id ) AS zz GROUP BY angler "; $total_inches_result = mysql_query($total_inches) or die(mysql_error()); $RowCount = mysql_num_rows($total_inches_result); $tablehead = "<table border='1'><tr> <th>Rank</th> <th>Team</th> <th>Angler</th> <th>Species</th> <th>Length</th></tr>"; $tablefoot = "</table>"; echo "There are $RowCount rows in your results.<br />"; $rank=1; while($row = mysql_fetch_array($total_inches_result)) { $team = $row['team_id']; $angler = $row['angler']; $species = $row['species']; $total = $row['zz']; $tabledetails .=<<<EOD <tr> <td> $rank </td> <td> $team </td> <td> $angler </td> <td> $species </td> <td> $total </td> <tr> EOD; $rank++; } $table .=<<<EOD $tablehead $tabledetails $tablefoot EOD; print $table; ?> -
Find the largest value for each group and sum
Skipjackrick replied to Skipjackrick's topic in MySQL Help
Ok.... I am just sort of working through the tutorial you sent me to.. I am getting results but its not displaying my results. Do you see anything weird? <?php //connect to the db include 'db_connect.php'; //Testing for total inches $total_inches = "SELECT team_id, angler, species_id, length FROM submit WHERE length = (SELECT MAX(length) from submit as total where total.angler = submit.species_id) "; $total_inches_result = mysql_query($total_inches) or die(mysql_error()); $RowCount = mysql_num_rows($total_inches_result); $tablehead = "<table border='1'><tr> <th>Rank</th> <th>Team</th> <th>Angler</th> <th>Species</th> <th>Length</th></tr>"; $tablefoot = "</table>"; echo "There are $RowCount rows in your results.<br />"; $rank=1; while($row = mysql_fetch_array($total_inches_result)) { $team = $row['team_id']; $angler = $row['angler']; $species = $row['species']; $length = $row['length']; $tabledetails .=<<<EOD <tr> <td> $rank </td> <td> $team </td> <td> $angler </td> <td> $species </td> <td> $length </td> <tr> EOD; $rank++; } $table .=<<<EOD $tablehead $anglerdetails $tablefoot EOD; print $table; ?> -
Find the largest value for each group and sum
Skipjackrick replied to Skipjackrick's topic in MySQL Help
In case you were interested....here is my table structure Fields +-------+------------+------------+----------------+-----------+-----------+ id team_id angler species_id points length +-------+------------+------------+----------------+-----------+-----------+ -
Find the largest value for each group and sum
Skipjackrick replied to Skipjackrick's topic in MySQL Help
Thanks let me read that....just a brief look over it looks like what I need.