Jump to content

pkedpker

Members
  • Posts

    182
  • Joined

  • Last visited

Everything posted by pkedpker

  1. Okay this is pretty complicated to even explain but I will try. I am attempting to match up 2 tables which I have no problem doing at the moment. But it doesn't take into account that when the 2 tables have rows that match up. The rows which match up after the first row (not always the rows will match up but it's possible). The newly matched rows will not take into account the previous row changes. Here is the query SELECT S.itemId, S.amount, S.price, S.sold, S.playerHash, B.itemId, B.amount, B.price, B.bought, B.playerHash FROM Buying AS B JOIN Selling AS S ON B.itemId = S.itemId AND B.price >= S.price AND S.sold < S.amount AND B.bought < B.amount ORDER BY B.price DESC LIMIT 100 When the first Seller finds a Buyer it should compute instantly that the Buyer already bought the Seller's item. `S.amount` is total amount of items Seller has to sell. `S.sold` is total amount of items Seller has sold (if this S.sold = S.amount then no items left to sell) `B.amount` is total amount of items Buyer has to buy. `B.bought` is total amount of items Buyer has bought (if this B.amount = B.bought then no items left to buy) So the first row should simulate both tables change the S.sold and B.bought and Don't Update database for both tables when the row is outputted those will be the predicted changes.. (I still wan't to handle changes myself in case the program I do it on crashes then It should be able to re-do the ones the program missed) Calculate amount left to sell. Calculate amount left to buy. Calculate proper amount sold and proper amount bought. My math could be wrong here but here is a shot what I am trying to do. From research you cannot use IF in Sqlite have to resort to using CASE WHEN .. THEN .. ELSE .. END Then again I don't even know how to use these variables or updating both tables temporarily and joining both updated temporarily tables amountBuyerNeeds = (B.amount - B.bought) amountSellerStock = (S.amount - B.sold) B.bought = IF(amountBuyerNeeds > amountSellerStock, (B.bought + amountSellerStock), B.amount) S.sold = IF(amountSellerStock > amountBuyerNeeds, (S.sold + amountBuyerNeeds), S.amount)
  2. Very nice thank you works perfect, except has to be date_credited not created but no problem. Works good too, learned how to use date function thanks
  3. How do I select specific rows from DATETIME based on DATETIME in betweens lets say Today is 2012-11-27 I would like to get a chart based on SUM(reward) for each day for a whole week in the past. By seeing the image below it should show the same amount for each day. I was thinking something like this but it seems to merge certain days together. SELECT SUM(reward) FROM referrers WHERE referrer = '{$_SESSION['username']}' AND date_credited >= (NOW() - INTERVAL 1 DAY) AND date_credited < (NOW() + INTERVAL 1 DAY) UNION ALL SELECT SUM(reward) FROM referrers WHERE referrer = '{$_SESSION['username']}' AND date_credited >= (NOW() - INTERVAL 2 DAY) AND date_credited < (NOW() + INTERVAL 2 DAY) UNION ALL SELECT SUM(reward) FROM referrers WHERE referrer = '{$_SESSION['username']}' AND date_credited >= (NOW() - INTERVAL 3 DAY) AND date_credited < (NOW() + INTERVAL 3 DAY) UNION ALL SELECT SUM(reward) FROM referrers WHERE referrer = '{$_SESSION['username']}' AND date_credited >= (NOW() - INTERVAL 4 DAY) AND date_credited < (NOW() + INTERVAL 4 DAY) UNION ALL SELECT SUM(reward) FROM referrers WHERE referrer = '{$_SESSION['username']}' AND date_credited >= (NOW() - INTERVAL 5 DAY) AND date_credited < (NOW() + INTERVAL 5 DAY) UNION ALL SELECT SUM(reward) FROM referrers WHERE referrer = '{$_SESSION['username']}' AND date_credited >= (NOW() - INTERVAL 6 DAY) AND date_credited < (NOW() + INTERVAL 6 DAY) UNION ALL SELECT SUM(reward) FROM referrers WHERE referrer = '{$_SESSION['username']}' AND date_credited >= (NOW() - INTERVAL 7 DAY) AND date_credited < (NOW() + INTERVAL 7 DAY) Output is Day Reward 1 0.43 2 0.84 3 1.17 4 1.38 5 1.60 6 2.03 7 2.58
  4. solved it with a overflow: hidden no scollbar at all.. couldn't find a decent way to remove min-height: 100%
  5. Wow thanks for all your advise it's good information. What do you think is causing the min-height: 100% to be added to body. I couldn't find it anywhere in style.css seems to be added by some javascript. Any way to figure out what adds it? Thanks for all your advise Figured it out.. the Google translator adds that min-height. Anyway to cancel out CSS without javascript? tried adding min-height:100%; !important to style.css but the style in body overwrites that.
  6. here you can clearly see the scrollbar also how do I fix this problem with the ad scaling from the right side? how do I make it scale after the logo
  7. The scroller gets added as soon as the top ad gets moved into position. You can see there is no scroller if you refresh the site and quickly see before the ad gets moved. Still looking for a solution. Thanks
  8. After I put a google ad on the top I had various problems with it. First problem the ad is positioned in a way that if you move the website right to left it's clipped on the right side. How do I clip it after the logo instead? (the left side). Biggest problem is that the top ad added a Scrollbar for no reason and I don't know how to remove it now. Website is http://www.CamSpark.com As for posting code it looks like this <div id="adwrapperTop"> <?php include("ads/googletop.html"); ?> </div> CSS #adwrapperTop { position: absolute; right: 25em; top: 10px; border-collapse: collapse; }
  9. perfect thanks jesirose SELECT referrer, whoreferred, SUM(reward) FROM referrers WHERE referrer='sspoke' GROUP BY referrer, whoreferred
  10. How would I go about getting whoreferred added up their reward and show it under name sspoke. Say I login sspoke I should see jayman there with a reward of 33+21=0.54 I also want to see all the other users other then jayman and their totals SUM'ed up. I have no clue how to go about making this query mysql> SELECT * FROM referrers; +----+----------+-------------+--------+---------------------+ | id | referrer | whoreferred | reward | date_credited | +----+----------+-------------+--------+---------------------+ | 1 | Admin | sspoke | 0.43 | 2012-04-24 14:04:06 | | 2 | Admin | sspoke | 0.43 | 2012-04-24 14:04:06 | | 3 | sspoke | jayman | 0.33 | 2012-04-24 14:04:06 | | 4 | sspoke | jayman | 0.21 | 2012-04-24 14:04:06 | +----+----------+-------------+--------+---------------------+
  11. I never used any remember me checkbox's once I login.. I close open browser i'm always logged in.. I have never touched cookies as they are completely useless.. my secret is sessions
  12. \x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0DPHCK\x00\x00\x00\x01\x00\x00\x00\x01 <html><body><script>alert(window.document.cookie);</script></body></html> is the PE Header for PNG file so it tricks the browser thinking it's loading a PNG file.. i think i'd use header() for this.. header("Content-type: image/png");
  13. how do I set a global variable for a javascript file loaded externally. Like.. <script type="text/javascript" src="js/client.js"></script> <script language="JavaScript"> var user = "pkedpker"; </script> <script type="text/javascript" src="js/client.js">var user = "pkedpker";</script> Both fail.. when I do alert('user = ' + user); inside of client.js.. I get back user = [object HTMLTableCellElement] note I did var user = "guest"; inside the file I still get user = [object HTMLTableCellElement] edit: maybe user is reserved keyword?? well..... I tried now I tried var username now and all seems to work but how should I do it? anyways code sample 1 or 2? for most browser support as possible. alright code sample 2 doesn't work anyways its stuck on guest mode
  14. Are those people just bad JavaScript programmers or is it a trick to get other browsers with bad JavaScript parsing to make it work? here is a example <script language="JavaScript"> <!-- function setsmiley(what){ tmp=document.getElementById("mytext"); tmp.value = tmp.value+" "+what+" "; tmp.focus(); } //--> </script> why the hell did he leave <!-- when --> is commented out anyways its pure stupidity from my side. Found this kind of error on google ads as well! had to remove the <!-- and //--> to save a few bytes! but is there any trick to this? leaving them in I mean
  15. there must be a trick .. but yah i guess i'll doo all variables before hand
  16. how do I compute math like subtraction in heredoc example.. <img height="6" width="{100-$myHP}"/> output is..... <img height="6" width="100-28"/> you know I want 72.. I'm making HP bars here and no way I cannot use heredoc as there is soo much HTML here its crazy. but if i do ${100-$myHP} I get a variable called 72 -.-.. but not value!.. so im stuck. Soo I tried {${100-$myHP}} and still nothing
  17. As for anti-spam you don't need a question thats old way of fixing this the new way... is storing everyone who submits the feedback's IP into a list.. and checking the list if someone submitted it then they cannot submit it for XX hours/days or EVER.. unless you empty the list.. its a permanent fix to any spam problem. People don't even use captchas due to just ip checking. It's easy to implement the ip check as well just google ip logging simple script
  18. 4294967295 = 32bit signed integer overflow happened and it's being read as unsigned integer.. basically what happened you had 0 points and you subtracted 10 from 0.. so you have -10.. and -10 = 4294967295 in unsigned integer.. change MYSQL table datatype to SIGNED integer and it will show as -10..
  19. I'm trying to calculate the odds of you losing or winning a match. To get started a team can have up to 6 fighters from level 1 to level 100 per fighter.. Now I want to calculate which team has a better odds of winning based on level and count of fighters per team as someone could enter with a team of 1 fighter.. which is level 100 and another person enters 6 fighters in his team all level 10.. it's obvious that 1 fighter will win.. but how can I get the percentage here? ATM when sql query is returning row.. I add up every fighters Level's together and the amount of fighters goes up by 1 everytime.. I do this for my team and opponent team and here is where I calculate the percentage of myself winning <?php $myLvls = 0; $myAmount = 0; $oppLvls = 0; $oppAmount = 0; //MYSQL Query.... etc while($r=mysql_fetch_array($res)) { $myLvls += $r["lvl"]; $myAmount += 1; } while($r=mysql_fetch_array($res)) { $oppLvls += $r["lvl"]; $oppAmount += 1; } if(($myLvls > 0 && $myAmount > 0) && ($oppLvls > 0 && $oppAmount > 0)) { $totalStrength = ($myAmount > $oppAmount ? 10 : (($myAmount / $oppAmount) * 10)); $totalStrength += ($myLvls > $oppLvls ? 100 : (($myLvls / $oppLvls) * 100)); $totalStrength = ($totalStrength == 200) ? 100 : $totalStrength; $totalStrength = number_format($totalStrength, 2); } ?> The Lvl's calculation is pretty good but when I add up that with amount of fighters percentage it's soo high it passes the 100% mark when its obvious you will lose or have a nearly impossible chance of winning.. I was having ideas like the amount the percentage for amount of fighters has to be calculated by a base of 6 which will make sense like.. like 1/6 = 16.67% 2/6 = 33.33% 3/6 = 50% 4/6 = 66.67% 5/6 = 83.33% 6/6 = 100% but of course thats only the amount of players I have now that percentage has to be lowered by the level total.. I guess since the highest level possible is 600 (100 per fighter if they are maximum level) then I have to use 600 somehow with whatever It's way to confusing for me.. can someone lend me a hand.
  20. thanks solved never knew about UNIONs.
  21. Was just wondering if it's possible to get 2 rows for like WHERE name = 'test' and WHERE name='test2' to return both rows in 1 query. Got this atm SELECT `pid`,`lvl`,`hatch` FROM pet p LEFT OUTER JOIN members m ON m.id = p.uid WHERE m.`name`='$myName' AND p.banked = 0 LIMIT 1 SELECT `pid`,`lvl`,`hatch` FROM pet p LEFT OUTER JOIN members m ON m.id = p.uid WHERE m.`name`='$opponentName' AND p.banked = 0 LIMIT 1 now how do i join both together in a single query and i dont want the rows returned to be in a strange order.. but in a order of how it was done first the myName then the opponentName and just get 2 rows? I'm not just asking for a handout i'm asking to learn.. from a example so i dont have to ask again.
  22. making a pokemon site like me I see? owner of gpxplus here
  23. how does this work function check_login_status() { // If $_SESSION['logged_in'] is set, return the status if (isset($_SESSION['logged_in'])) { return $_SESSION['logged_in']; return $_SESSION['username']; return $_SESSION['id']; } return false; } you know it will only return either false or the value of logged_in username id will never be returned.. something you gotta learn in programming return exits function right away.. right when it sees it.. if statement may make u be able to use multiple returns.. but as soon as code execution reaches a return its over.. and trust me. if you think just because logged_in is not set of something it will skip the return and go to the second one.. then your mistaken because return exits on ANYTHING.. its like similar to die();.. just without exiting the script execution just function jump. Plus its used in all programming languages..
  24. work of this I'm not good at javascript either.. just started it today but its not hard to pick it up.. I mean i did in a day.. <?php //cOLOrZ <form name="myform" action="grading.php" method="POST"> <SELECT> <OPTION value="Third Grading" selected onClick="submitform();">3rd</option> <OPTION value="Second Grading" onClick="submitform();">2nd</option> <OPTION value="First Grading" onClick="submitform();">1st</option> </select></form> <SCRIPT language="JavaScript"> function submitform() { document.myform.submit(); } </SCRIPT> ?> Note that above is not PHP file its just a plain html file.. BUT IT calls a PHP file.. with a $ans = $_POST['Third Grading'];
×
×
  • 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.