Jump to content

cdoyle

Members
  • Posts

    164
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

cdoyle's Achievements

Member

Member (2/5)

0

Reputation

  1. that works perfect, thanks again.
  2. I'm sorry, I didn't describe it quite right the first time. I should have said I want to display the players who have been marked an 'enemy' the most (top 5).
  3. Thanks for your help. I tried this but it's not quite working, if I wanted to display the count I would use 'enemies' correct? Right now, all entries are showing '1' as the total enemy count. I did write it a little differently than you though. I basically want to see the players who have been marked as a 'enemy' the most So I did this, I think yours would show who marked the most people as an enemy? but I could be wrong. SELECT enemy_id, COUNT(DISTINCT enemy_id) as enemies FROM tablename GROUP BY enemy_id ORDER BY enemies DESC but everything is showing 1.
  4. Hi, this seems like it would be easy, but I can't seem to get it to work. Here is what I want to do, I have a table that has the following structure. ID player_id enemy_id I want to have to display the top 5 players who have the most enemies so I need to group the 'enemy_id' field and then sort it by the highest count. so if I have data like this row 1 | enemy_id=121 (ME) row 2 | enemy_id=134 (Someone else) row 3 | enemy_id=121 (ME) the result would look something like this on my page ME = 2 someone else 1 How can I do this? Thanks Chris
  5. I was just coming back to edit my post to say that it's unsigned currently.
  6. Hello, this has been a topic that has confused me for awhile, and not sure how to get around it. I have an RPG and the players have bank accounts, but after several years of game play. Some players are running into issues where we just can't store large numbers in the database anymore. http://www.caraudiocentral.net/CAC_Mafia_Life I currently have the field as BIGINT(20). I've read that one solution is to use a VARCHAR, but you can't do any math calculations with this. So this isn't a solution for me, since this is game cash, and it has to be calulated everytime a transaction is done. What are my options with these very large numbers? Thanks Chris
  7. Thank You, I must have removed the Order by when i was troubleshooting it, and forgot to put it back. It's all working now.
  8. Hi, Sorry to have to bump this, but it's not quite working 100% and I'm not sure why. I noticed that if you spy on the same person within a few minutes of each other, they will group like they are supposed too. but if you spy on someone say an hour later, it no longer groups that data with the previous one. It will create a new grouping, but I don't see in the code why it would do this. I'm using ADODB that's why my code looks a little different, but it should work the same. Here is what I have. $gethistory = $db->execute("SELECT p.username, s.ID, p.id as playerid, s.sp y_id, s.strength, s.defense, s.speed, s.money, s.timestamp, s.weapon, s.armor FROM spy_log s INNER JOIN players p on s.spy_id = p.id WHERE s.player_id=?", array($player->id)); $last_spied_player = false; //Flag to track change in spied player if ($gethistory->recordcount() == 0) { echo "You have not spied on anyone yet, <a href='members_all.php'>Select a player and hire a spy to get some information</a>"; } else { while ($result = $gethistory->fetchrow()) { //Display spied player name if different than last record if ($last_spied_player !== $result['username']) { //Add double line break if not first spied player if ($last_spied_player !== false) { echo "<br><br>\n"; } //Set flag $last_spied_player = $result['username']; //Display player header echo "<strong>{$last_spied_player}</strong><br/>"; } //Display spied details echo "<span style='font-size: 10px; '>" . date('m-d-Y', $result['timestamp']) . " Strength: " . number_format($result['strength']) . " Defense: " . number_format($result['defense']) . " Speed: " . number_format($result['speed']) . " Cash $" . number_format($result['money']) . "</span> <a href='spyhistory.php?act=delete&ID=" . $result['ID'] . "'>Delete</a><br>"; } } } Do you see anything that would cause it to not group items that were saved later on in time?
  9. @Jesirose, you had the right solution, but I think you specified the wrong field. The OP is wanting to show a header whenever the "player" changes. @cdoyle, The solution is basically what jesirose stated, but change it to apply to the player name. Here is some mock code: $query = "SELECT spied_player, stat_1, stat_2, date FROM stat_table WHERE spying_player = '$playerID' ORDER BY spied_player, date"; $result = mysql_query($query); $last_spied_player = false; //Flag to track change in spied player while($row = mysql_fetch_assoc($result)) { //Display spied player name if different than last record if($last_spied_player !== $row['spied_player']) { //Add double line break if not first spied player if($last_spied_player !== false) { echo "<br><br>\n"; } //Set flag $last_spied_player = $row['spied_player']; //Display player header echo "<b>{$last_spied_player}</b><br>\n"; } //Display spied details echo "Date: {$row['date']}, {$row['stat_1']}, {$row['stat_2']}<br>" } This worked perfect! thank you everyone for your help. Chris
  10. Hi, I don't have any code yet, I've been trying to find examples of what I want to do but not coming up with anything. basically I want to query my table but instead of just displaying everything row after row. I want all the data for a specific player to be grouped together, and do this for each player a person may have spied on.
  11. i've been trying to search for a solution on what I want to do, but not sure if I'm looking for the correct term Here is what I want to do, I'm creating a page in my game that allow users to see a history of their spying records of other players. Instead of just a long list of results, I would like to group the results by the player they spied on. example: Instead of this a normal table of results. player 1 stat 1, stat 2, date player 2 stat 1, stat 2, date player 1 stat 1, stat 2, date player 1 stat 1, stat 2, date what I want it to look like is this, all the results for a player spied on grouped together. player 1 Date: stat 1, stat 2, Date: Stat 1, stat 2 Player 2 Date: Stat 1, Stat 2 Anyone have any ideas how to display the results like this?
  12. ym_chaitu, I tried your sample code, and it seems to be working, the image is uploading. I'm just curious about it though, maybe this code isn't complete. How does the filesize, and extensions get checked before they are uploaded? I don't see anything in the code, just in the form about the value of the file size. But I don't see anything being done on the server.
  13. I'm not sure if this is really a PHP or HTML question, but hopefully it's a simple one. Basically I have a page, that displays a specific person's information. In my user_table I have a field labeled as 'active' 0 for not active 1 for active. So on this page, I want to create a yes/no dropdown and have it display the current status. So I started to create a simple html dropdown, but I'm not sure how to get it to display the current status as the default.. <select name="active"> <option value="1">Yes</option> <option value="0">No</option> </select> $getstaff1['active'] <<< it will either be a 1 or a 0. This is the variable from my query that is ran when the page is opened. I'm not sure how to use this, to make the dropdown display the correct status. Thanks
  14. <div id="holder"> <div id="name" class="item"></div> <div id="pass" class="item"></div> </div> js: <script src="path_to_jquery"></script> <script your js> if(MyHttpRequest.readyState==4){ $(".item").each(function(){ $(this).html(''); }); $("#"+target_div).html(MyHttpRequest.responseText); } [/code] that will empty each of your subdivs, and then display the one desired one's new content. OK, going to give this a shot. so I've added the path to jquery to my page, so then I add this <script your js> if(MyHttpRequest.readyState==4){ $(".item").each(function(){ $(this).html(''); }); $("#"+target_div).html(MyHttpRequest.responseText); } </script> Do I still use the PHP page to get the message? Or am I pulling the message I want to display from somewhere else?
×
×
  • 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.