Jump to content

cdoyle

Members
  • Posts

    164
  • Joined

  • Last visited

Everything posted by cdoyle

  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?
  15. If I were to use a div instead, would I still need to add that for each field in my form? Or would I be able to make it work without having to add a line of code for each field?
  16. Did you see anything wrong in my example?
  17. Yes, I have a test page here. http://www.caraudiocentral.net/CAC_Mafia_Test_Site/register.php
  18. I'm using the technique from the sticky http://www.phpfreaks.com/forums/index.php/topic,115581.0.html Looking at that script, I see this. I don't see a += MyHttpRequest.onreadystatechange = function () { if(MyHttpRequest.readyState == 4) // done and responded { document.getElementById(target_div).innerHTML = MyHttpRequest.responseText; // display result } else { document.getElementById(target_div).innerHTML = MyHttpLoading; // still working } } MyHttpRequest.send(null); } else { document.getElementById(target_div).innerHTML = ErrorMSG; // the browser was unable to create a httprequest } } The messages are kept in my php file, with a switch statement Looks something like this. case 'namefield': { echo "<h3>Select a username</h3>"; echo "This will be the name you use to log into the game with."; break; } case 'passfield': { echo "<h3>Select a Password</h3>"; echo "Enter a password, Your password may contain only alphanumerical characters."; break; } any ideas on how to make this work the way I need?
  19. anyone know how to make the first message clear from the div, when the next form field is selected?
  20. Anyone have any ideas at all or see anything wrong with my code? it doesn't make sense to me, but IE normally doesn't.
  21. Hi, I have another question related to my forms. I'm using Ajax to display messages when a user click on each field. <input type="text" id="username" name="username" onfocus="javascript: MyAjaxRequest('namefield','registercheck.php?act=namefield')" <input type="password" name="password" value="<?=$_POST['password'];?>" onfocus="javascript: MyAjaxRequest('passfield','registercheck.php?act=passfield')"/> Then I have another div, where the messages are displayed. <span id="namefield"></span> <span id="passfield"></span> That works fine, but when they click on the next field. The new message appears but the old one doesn't go away. How would I clear the previous message from the div?
  22. I tried it on another PC yesterday using IE7, and I noticed that the messages would sometimes appear???? It seemed to randomly work.. Is the way I'm doing it correct, or is there a better way?
  23. anyone have any ideas on this one? I'm stumped.. Everything works fine in firefox, and the image appears OK in IE, but the text doesn't??
  24. I'm a little new to Ajax, and I have a form on my site that when a users enters a number. A little message will appear telling them either it's OK or to try again with a little image next to the text. What I have works fine in firefox, but in IE only the image appears.. Not sure why? Here is the code I have on my textbox <input type="text" id="num1" name="num1" size="2" onblur="javascript: MyAjaxRequest('check1','lottovalidate.php?act=1&id=', 'num1')"> and I'm using this span ID to display it <span id="check1"></span> and here is lottovalidate.php case '1': $num1 = $_GET['id']; if (!is_numeric($num1) || $num1 <= 0 || $num1 >=10) { echo "<img src=images/error.gif width='10px' height='10px' alt='input error' title='input error' /><span class='notification'>\nPick a number between 1-9</span>"; } else { echo "<img src=images/OK.gif width='10px' height='10px' alt='Input OK' title='Input OK' />"; echo "Pick 2 OK!"; } break; not sure why the image would appear just fine, but the text won't in IE? any ideas?
×
×
  • 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.