Jump to content

NICON

Members
  • Content Count

    26
  • Joined

  • Last visited

Community Reputation

0 Neutral

About NICON

  • Rank
    Member
  1. if ($number <= 9 || $yourhp <= 0) { $log[] = $number . ":&nbsp;" . $defender->formattedname . " hit you for " . prettynum($damage) . " damage using their " . $defender->weaponname . ". <br />"; } if ($number <= 9 || $theirhp <= 0) { $log[] = $number . ":&nbsp;" . $defender->formattedname . " hit you for " . prettynum($damage) . " damage using their " . $defender->weaponname . ". <br />"; } Adding these 2 if statements in limits the amount of data stored in the array... Which may have been the issue all along just way to much info in the array? I was getting a 500 error because of it.
  2. Should I toss in an if statement limiting the output from the $log to the first few and last loop?
  3. The current version running on the server is 5.5.9. It executes for roughly 30 to 40 seconds then gives an error screen. If I remove the $log in the while loop it does execute properly. Just wont give any output on the screen as to the results of this section of code.
  4. I have a while loop in a script that is running for a very long time due to the large values that are passing through it. Below is the link to the pastebin code and code embedded in this forum. Loop Statement Snipet if (!$user_class->invincible) { if (!$defender->invincible) { while ($yourhp > 0 && $theirhp > 0) { $damage = round($defender->moddedstrength) - $user_class->moddeddefense; $damage = ($damage < 1) ? 1 : $damage; if (!$wait) { $yourhp = $yourhp - $damage; ++$number; $log[] = $number . ":&nbsp;" . $defender->formattedname . " hit you for " . prettynum($damage) . " damage using their " . $defender->weaponname . ". <br />"; } else $wait = 0; if ($yourhp > 0) { $damage = round($user_class->moddedstrength) - $defender->moddeddefense; $damage = ($damage < 1) ? 1 : $damage; $theirhp = $theirhp - $damage; ++$number; $log[] = $number . ":&nbsp;" . "You hit " . $defender->formattedname . " for " . prettynum($damage) . " damage using your " . $user_class->weaponname . ". <br />"; } } $log = array_slice($log, -10, 10, true); foreach($log as $text) echo $text; } else $yourhp = 0; } else $theirhp = 0; My issue is that $yourhp and $theirhp can be in the 100's of thousands causing this to loop half a million plus times. I was curious if there was a way to only show the first few lines and last few lines of this but still retain the increment value that's created? Thanks so much in advance. NICON
  5. I was looking for a bit of documentation breaking down the post() method for jQuery thanks so much. So I tried this trying to make sense of what exactly is happening. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { alert(d); }); location.reload(); } while keeping the $mtg function in the ajax file and it does as expected. It returns the data from that function in the browsers alert window (not sure if thats exaclty what its called) telling me: domain name says: "$mtg function plain text blah blah" Then asking for OK. When OK is pressed the page refreshes and the data is gone. I will dig deeper on how to show that text being returned in html format in lieu of that alert window.
  6. Oh thats my fault I had the other forum open in another window and clicked on this tab by accident. Should I repost or can it be moved?
  7. I have just begun dabbling with javascript as a hobby and have a very crude understanding of php so please bare with me, I am a noob! I am using a javascript onclick button to reference the function shown below. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { }); location.reload(); } When the button is pressed and the function executes it does as it should. It deletes the forum reply post as its told and the page reloads and the post is gone! But without some sort of explanation, success message or something telling me that it did what its intended is very unsatisfying. I read around and found that an additional function is needed to give me a little message. success : function() { var x="Success"; alert(x); } Looks simple enough and one would think should be easy to incorporate but when I add it in every way shape or form I cannot get it to work. The original function wont even work after adding this. Below is basically what I am wanting to do but not quite sure how to go about it. function deleteReply(fpid) { $.post("ajax_forumdelete.php", {'reply': fpid}, function (d) { }); success : function() { var x="<?php $mtg->success("Reply has been deleted."); ?>"; alert(x); location.reload(); } } I want to use the php $mtg->success() function to echo the message in the pre defined output location and format and want to output the message after the reload... Any ideas on how to go about this?
  8. You know that's another oversight with the id but I have it set up to echo the value for each type using: <th width='20%'>Leveler OTH/OTD</th> <td width='30%'>" . $row['LevOTH'] . " / " . $row['LevOTD'] . "</td> I will tweak it a bit and see if I can get the desired output. Thanks again.
  9. Oh my I was a mile off... So I took Jacques's advice and did this $db->query("SELECT id, count(*) total, sum(case when type = 'Leveler OTH' then 1 else 0 end) LevOTH, sum(case when type = 'Mugger OTH' then 1 else 0 end) MugOTH, sum(case when type = 'Buster OTH' then 1 else 0 end) BustOTH, sum(case when type = 'Mobster OTH' then 1 else 0 end) MobOTH, sum(case when type = 'Leveler OTD' then 1 else 0 end) LevOTD, sum(case when type = 'Mugger OTD' then 1 else 0 end) MugOTD, sum(case when type = 'Buster OTD' then 1 else 0 end) BustOTD, sum(case when type = 'Mobster OTD' then 1 else 0 end) MobOTD FROM ofthes_winners WHERE userid = ?"); $db->execute([$profile->id]); $row = $db->fetch_row(true); Then I fixed the crons (day and hour). Then fixed the query on each page where that data was initially reflected. $db->query("SELECT * FROM ofthes_winners WHERE type NOT LIKE '%OTH%' ORDER BY timestamp DESC LIMIT 100"); $db->execute(); $rows = $db->fetch_row(); All is functioning perfectly and my database file is now down a table it didn't need! Thanks so much for everyone's help though.
  10. Jacques you are probably more right here than I initially intended. Its probably going to be much much easier to modify the 6 other files to make this a single table than fighting with this ambiguous query. However I would still like to know how to accomplish this for future knowledge in the event I am working with 2 very different tables.
  11. Thats my fault I wasnt thinking at all there. Okay so I have combed through but my scenario seems to be very unique. This is what I have so far. SELECT (SELECT id, count(*) total, sum(case when type = 'Leveler OTH' then 1 else 0 end) LevOTH, sum(case when type = 'Mugger OTH' then 1 else 0 end) MugOTH, sum(case when type = 'Buster OTH' then 1 else 0 end) BustOTH FROM othwinners WHERE userid = 19 UNION ALL SELECT id, count(*) total, sum(case when type = 'Leveler OTD' then 1 else 0 end) LevOTD, sum(case when type = 'Mugger OTD' then 1 else 0 end) MugOTD, sum(case when type = 'Buster OTD' then 1 else 0 end) BustOTD, sum(case when type = 'Mobster OTD' then 1 else 0 end) MobOTD FROM otdwinners WHERE userid = 19) But sql keeps giving me "The used SELECT statements have a different number of columns". Now if I remove the 4th sum row in the second SELECT I get "Operand should contain 1 column(s)". So I know I am doing something wrong but cant pin down what so I tried: SELECT id, count(*) total, sum(case when type = 'Leveler OTH' then 1 else 0 end) LevOTH, sum(case when type = 'Mugger OTH' then 1 else 0 end) MugOTH, sum(case when type = 'Buster OTH' then 1 else 0 end) BustOTH FROM othwinners WHERE userid = 19 UNION ALL SELECT id, count(*) total, sum(case when type = 'Leveler OTD' then 1 else 0 end) LevOTD, sum(case when type = 'Mugger OTD' then 1 else 0 end) MugOTD, sum(case when type = 'Buster OTD' then 1 else 0 end) BustOTD FROM otdwinners WHERE userid = 19 Removing the first SELECT completely and the query runs but only gives me results for the first SELECT id total LevOTH MugOTH BustOTH 24 319 79 77 86 18 18 4 6 6 It appears there is more data to be obtained but is not showing. I base this on the value of id and total do not equate to the values of LevOTH MugOTH and BustOTH. What am I missing here?
  12. So go with Union despite the fact the data is not being repeated or duplicated in either table. I can UNION on the userid sense that is the only info that corresponds with data from one to the other?
  13. Yes I want to keep moving forward and not redo something right this second if it does not need to be. For the sake of function that is. All of my types are different. Very minute but all different. Each entry has a unique id. As I said both query's work independently but cant figure out how to combine them. I completely understand combining the tables is a good idea. But the data in each table is not the same. One table is updated hourly vs the other which is updated daily. So in those tables there is not duplicate data. Just a unique entry hourly in the othwinners and daily in the otdwinners.
  14. I certainly agree but this wasn't my masterpiece and at this time I am unable to change it without messing up other portions of the site.
  15. I am wanting to combine the following two query's into a single db hit. $db->query("SELECT id, count(*) total, sum(case when type = 'Leveler OTH' then 1 else 0 end) LevOTH, sum(case when type = 'Mugger OTH' then 1 else 0 end) MugOTH, sum(case when type = 'Buster OTH' then 1 else 0 end) BustOTH FROM othwinners WHERE userid = ?"); $db->execute([$profile->id]); $db->query("SELECT id, count(*) total, sum(case when type = 'Leveler OTD' then 1 else 0 end) LevOTD, sum(case when type = 'Mugger OTD' then 1 else 0 end) MugOTD, sum(case when type = 'Buster OTD' then 1 else 0 end) BustOTD, sum(case when type = 'Mobster OTD' then 1 else 0 end) MobOTD, FROM otdwinners WHERE userid = ?"); $db->execute([$profile->id]); The two on there own work perfect but I am unsure if using INNER JOIN or another JOIN method is going to get me what I am looking for. Both tables have the exact same columns the only difference's are in come cases the $profile->id may or may not exist and if not I will sort those with !num_rows() and the conditions for type change from one table to the other. Columns are id, userid, type, howmany, and timestamp...
×
×
  • 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.