Jump to content

dean7

Members
  • Posts

    309
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

dean7's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Yeah I am storing as a interger timestamp. So would this only show the users who have done something in the pass year? So users who haven't been on for 2-3-4 years won't be shown? Thanks for all your help!
  2. Hey all, I'm coding a script which gets all the money what is in the game but I'm wanting it to only show the users who have been active in the past year. So if you've been active your money adds on if you've not been online for a year it don't add the money on, if that makes sense? Here is my little bit of code I'm working with: $LastMove = mysql_query("SELECT last_action, last_login FROM users") or die(mysql_error()); $Move = mysql_fetch_object($LastMove); $Movement = $Move->last_action; $newTimestamp12 = strtotime('-1 years', $Movement); $date3 = new DateTime("@$newTimestamp12"); $New3 = $date3->format('Y') . "\n"; $stats=mysql_query("SELECT SUM(money),COUNT(id),SUM(exp) FROM users WHERE banned = 'n' AND active = 'y' AND last_action <= '$New3'"); Last_action is just time() which gets updated soon as them come online and are doing things on the site. With my code, would that only show users who have been active for the past year? Hope I've explained that well enough. Thanks for any help provided
  3. I didn't explain it very well. Let me try again, I'm coding a page to show users who haven't logged in for so many years (2,3,4,5 years etc). In my database I'm holding the last login like this: 14th Dec 16, 16:00. How would I do a query to select all the users from the year posted? Hope this is slightly clearer
  4. Hey guys, just a quick question, I'm wanting to select all the inactive users from the database who have been inactive for like 2 years, 3 years, 4 years etc from their last login but how would I go by doing this? I mean I'm guessing you would get all the users which are < the date posted but I'm unsure how I can get the results to what I'm after? Any help is appreciated. Thanks!
  5. Yeah I have the <form></form> tags around the table just not shown in that piece of code, and no its not the full lot its just the bidding side of things piece of code as the rest works to how I like it. It should be submitting the value of whats in the text box but when clicking it just flashes my page and does nothing
  6. Hey all, I'm coding a auction page for my website which allows users to bid on certain items without leaving the page, but what I'm getting is when you put your amount in then press the submit putting it returns nothing, this is what I have: This shows the auctions to bid on echo '<tr> <td width="20%" bgcolor="#707070 ">'.htmlspecialchars($Market->carforsale).'</td> <td width="10%" bgcolor="#707070"><a href="Market.php?viewcar='.htmlspecialchars($Market->carid).'" target="mainFrame">View Car Stats</a></td> <td width="15%" bgcolor="#707070">£'.htmlspecialchars(number_format($Market->price)).'</td> <td width="15%" bgcolor="#707070"><a href="profile.php?view='.htmlspecialchars($TheBidderIs).'" target="mainFrame">'.htmlspecialchars($TheBidderIs).'</a></td> <td align="center" width="15%" bgcolor="#707070">£<input name="MakeBid" type="text" id="MakeBid" value="'.htmlspecialchars($price).'" class="textinput"><input name="BidCar" type="submit" id="BidCar" class="button" value="Make Bid"></td> <td width="15%" bgcolor="#707070">'.htmlspecialchars(MakeTimeLeft($Market->timeleft)).'</td> <td width="10%" bgcolor="#707070">'.$RemoveButton.'<input type="hidden" name="theid" value="'.htmlspecialchars($Market->id).'"></td> </tr>'; This is the code to submit the bid. (Not actually tested as come across the issue with submitting) if (strip_tags($_POST['BidCar']) && strip_tags($_POST['MakeBid'])){ $MakeBid = strip_tags(htmlspecialchars(trim($_POST['MakeBid']))); if ($Market->seller == $Username){ echo "<br /><table class='tableborder' width='20%' cellpadding='1' cellspacing='0' border='1' align='center'> <tr> <td class='error_header' align='center'>Error</td> </tr> <tr> <td align='center'>You cannot bid on your own Auctions!</td> </tr> </table> <br />"; }elseif (strlen($MakeBid < 100)){ echo "<br /><table class='tableborder' width='20%' cellpadding='1' cellspacing='0' border='1' align='center'> <tr> <td class='error_header' align='center'>Error</td> </tr> <tr> <td align='center'>Your bid must be £100 or more!</td> </tr> </table> <br />"; }elseif($MakeBid < $Market->price){ echo "<br /><table class='tableborder' width='20%' cellpadding='1' cellspacing='0' border='1' align='center'> <tr> <td class='error_header' align='center'>Error</td> </tr> <tr> <td align='center'>Your bid must be more than ".htmlspecialchars(number_format($Market->price))."!</td> </tr> </table> <br />"; }elseif($MakeBid > $UsersTable1->money){ echo "<br /><table class='tableborder' width='20%' cellpadding='1' cellspacing='0' border='1' align='center'> <tr> <td class='error_header' align='center'>Error</td> </tr> <tr> <td align='center'>You don't have enough money to bid!</td> </tr> </table> <br />"; }else{ // Update Bidded - Give money back to outbidder if is a outbidder - Send message to Outbidder $BidderMoney = $UsersTable1->money; $NewMoneyBidder = $BidderMoney - $MakeBid; $BidderNewMoney = $db->prepare("UPDATE `UsersRegTable` SET money = :money WHERE username = :username"); $BidderNewMoney->bindValue(':money', $NewMoneyBidder); $BidderNewMoney->bindValue(':username', $Username); $BidderNewMoney->execute(); $UpdateBidMarket = $db->prepare("UPDATE `market` SET bidder = :bidder, price = :price WHERE id = :marketid"); $UpdateBidMarket->bindValue(':bidder', $Username); $UpdateBidMarket->bindValue(':price', $MakeBid); $UpdateBidMarket->bindValue(':marketid', $Market->id); $UpdateBidMarket->execute(); echo "<br /><table class='tableborder' width='20%' cellpadding='1' cellspacing='0' border='1' align='center'> <tr> <td class='header' align='center'>Success</td> </tr> <tr> <td align='center'>You have successfully bidded for that car!</td> </tr> </table> <br />"; I'm not sure why its not subbmitting any data? its also not giving me any errors saying why in my code and nothing in the error log. Thank you for any help given
  7. I've just been re looking to find that I missed placed a }. After reading what Mac_gyver said about the if() elseif() made me see it ! Thanks
  8. Hey guys I've got this script which I've been coding which allows users to stock cars.. I've been testing it as I code it in which all the error messages display at the right time work on hitting submit but when it comes to the time to update the database it just refreshes the page and don't do anything. I cannot work out the reason why? elseif (is_numeric($BuyCars)){ // Form has value, form is ALSO a number // Now get cost of the car to stock and how many they want // $Stocked is CarName $CarInfo = $db->prepare("SELECT * FROM `cars` WHERE carname = :carname"); $CarInfo->bindParam(":carname", $Stocked); $CarInfo->execute(); $CarReal = $CarInfo->rowCount(); $GetTheStockNow = $db->prepare("SELECT * FROM `Dealercars` WHERE location = :location AND carname = :carname"); $GetTheStockNow->bindParam(":location", $DeLoc); $GetTheStockNow->bindParam(":carname", $Stocked); $GetTheStockNow->execute(); $GetTheThe = $GetTheStockNow->fetchObject(); if ($CarReal != "1"){ echo "Failed finding car"; }elseif ($CarReal >= "1"){ // Car Found $OldCarStats = $CarInfo->fetchObject(); $BuyPrice = $OldCarStats->value; // Value of Car from defult value $CostOfBuy = $BuyPrice * $BuyCars; // Cost of stock $Money = $UsersTable1->money; // $Usernames money // Has the $Username got enough money to buy the stock? if ($UsersTable1->money < $CostOfBuy){ echo "You dont have enough money to buy this amount of stock!"; }elseif ($UsersTable1->money >= $CostOfBuy){ $StuffStock = $GetTheThe->stock; $NewMoney = $Money - $CostOfBuy; // Money after buying stock $NewStock = $StuffStock + $BuyCars; // The New Stock // Take the money from user for buying stock $TakeMoneyAway = $db->prepare("UPDATE `UsersRegTable` SET money = :money WHERE username = :username"); $TakeMoneyAway->bindValue(':money', $NewMoney); $TakeMoneyAway->bindValue(':username', $Username); $TakeMoneyAway->execute(); // Update thier car dealership with the stock they just brought $UpdateStock = $db->prepare("UPDATE `Dealercars` SET stock = :stock WHERE location = :location AND carname = :carname"); $UpdateStock->bindValue(':stock', $NewStock); $UpdateStock->bindValue(':carname', $Stocked); $UpdateStock->bindValue(':location', $DeLoc); $UpdateStock->execute(); echo "You successfully brought ".htmlspecialchars(number_format($BuyCars))." for £ ".htmlspecialchars(number_format($CostOfBuy)).""; } Am I missing something very obvious here ? Thanks for any help given
  9. Hey guys, I'm currently coding a forum for my site which is just being made for a time waster and to see what I can actually do but in the forum I'm trying to make it so certain forum topics show at the top of the table, for example, Id want Important topics, then Sticky topics the basic topics; Important: Test Sticky: Test Test That sort of format. Regardless of the last reply in the topics I want the forum to always hold that layout. So if there was 3 "Important" topics the topic with the newest reply will be on top but if there is a new reply in the normal topics I want that at the top but below Important and Sticky. I've currently got: if (($Topics->important == "2") AND ($Topics->locked == "2")){ $TitleF = "<strong><u>Important:</u></strong> <a href='Right.php?topicid=$Topics->id' target='frameright'>".check($Topics->topicname)."</a> (Locked)"; }elseif (($Topics->important == "2") AND ($Topics->locked == "1")){ $TitleF = "<strong><u>Important:</u></strong> <a href='Right.php?topicid=$Topics->id' target='frameright'>".check($Topics->topicname)."</a>"; }else{ $TitleF = "<a href='Right.php?topicid=$Topics->id' target='frameright'>".check($Topics->topicname)."</a>"; } Further down my code to try to display the topics how I want I tried this: $Important = $Topics->important; $Sticky = $Topics->sticky; if ($Important == "2"){ $Top = $TitleF; }elseif ($Sticky == "2"){ $Middle = $TitleF; }else{ $Bottom = $TitleF; } echo "".$Top."".$Middle."".$Bottom." </td> </tr>"; All that seems todo is just display the topics but completely wrong. Is there another way I should be going around this? Thanks!
  10. $tot = 0; foreach ($_POST['select_car'] as $car_id => $car_value){ $tot += $car_value; } echo $tot; That made it work, thank you for your help.
  11. Yes thank you , thats what I was aiming for as I wanted to check the value of the car is the same from in the database. As $car_value is holding each value of the selected cars how would I add all the selected car values up? I've read something about array_merge or could I just do sum($car_value)? Thanks
  12. So would this be how you mean for the form? <input id="select_car" name="select_car['.$CarID.']" type="checkbox" value="'.$CarValue.'" onclick="CountCheck()" /> The for the PHP bit: if (isset($_POST['sell_selected'])){ $PostValues = $_POST['select_car']; foreach($PostValues as $value) { $GetInfo = $db->prepare("SELECT * FROM garage WHERE id = :id"); $GetInfo->bindParam(":id", $value); $GetInfo->execute(); $CarInformation = $GetInfo->fetchObject(); } } When I try getting the information from the database it says: Notice: Trying to get property of non-object even thought the obj should be fine as I'm getting the ID from the checkbox?
  13. Hey guys, I've got problem which seems it should be so simple to resolve but I just can't put it together . I'm needing to show all of the values of the Check Boxes clicked when I hit submit, I have this: echo ('<tr><td><input id="select_car" name="select_car[]" type="checkbox" value="'.$CarID.'"" onclick="CountCheck()" /><a href="?getin='.$CarID.'">'.$CarName.'</a> ('.$CarIDCol.')</td><td><a href="?repair='.$CarID.'">'.$CarDamage.'%</a></td><td><a OnClick="javascript: return confirm(\'Are you sure you want to sell?\');" href="?sell='.$CarID.'">£'.number_format($CarValue).'</a><input type="hidden" name="values[]" id="values[]" value="'.$CarValue.'"></td><td><a href="?stats='.$CarID.'">View Stats</a></td></tr>'); In my form: <input name="sell_selected" type="submit" id="sell_selected" value="Sell Selected" class="button" onClick="JavaScript:return confirm('Are you sure you want to sell?');" /> if (!empty($_POST['sell_selected'])){ foreach ($_POST['values'] as $value){ echo $value; } } With my code its displaying all the values of even the ones which haven't been checked? How can I make it so it only shows the values of the checked checkboxes? Only needing that as once I can see them values I need to add them together to give the final figure of the extra money of all things sold Thanks for any help
  14. I'm not sure how to hold the current week and yeah the week will be the same for everyone
  15. Yeah sorry its hard explaining what I want to achieve. Its dont matter what this week would start as. If this week is week one, next week would need to be week two, or the other way around. Week to start Sunday and end Saturday, so like Saturday at midnight it would change to the next week
×
×
  • 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.