Jump to content

[SOLVED] time question???


darkfreaks

Recommended Posts

okay on offers.php there is a variable called $myoffers which pulls all offers from the database i was wondering is there anyway i can pull up those offers based on newest time put into the database then return it so if it has been there for fifteen minutes it will not allow you to cancel the offer ???

 

 

Offers.php:

<?php
$page_title = "Chicka Trade Center | View Your Offers";
require_once("../header.inc.php");
$myoffers = mysql_query("SELECT DISTINCT(trade_id), item_id, user_id, cp  FROM `trade_offers` WHERE `user_id`='$userid' LIMIT 0,1");

echo "$openHTML";
echo "<a href='maketrade.php?view=trades'>Trading Post Main</a> | <a href='mytrades.php'>Browse Lots</a> | <a href='$PHP_SELF'>Offers You made</a>
<br />";



while ($view = mysql_fetch_array($myoffers)) {
$getofferid = mysql_fetch_array(mysql_query("SELECT * FROM `trade_offers` WHERE `user_id`='$userid' AND `item_id`!=''"));
$gettradeowner = mysql_fetch_array(mysql_query("SELECT * FROM `trades` WHERE `id`='$view[trade_id]'"));
$getowner = mysql_fetch_array(mysql_query("SELECT * FROM `members2` WHERE `id`='$gettradeowner[owner]'"));
$getitems = mysql_query("SELECT * FROM `trade_offers` WHERE `trade_id`='$getofferid[trade_id]' AND `trade_id`!=''");

echo "<center><table cellpadding='0' cellspacing='2' border='1' style='border-style:solid;border-color:#eeeeee;border-width:1px;' bordercolor='#eeeeee'>
	<tr>
<td bgcolor='#eeeeee' colspan='2'><b>Offers you have made</b></td>
	</tr>
<form action='$PHP_SELF?action=cancel' method='post'><tr>
<td bgcolor='#eeeeee'>";

echo "<pre><b>Offer $getofferid[id]			Lot $view[trade_id]</b><br />				(owned by <a href='user_profile.php?game=1&user=$getowner[display_name]'>$getowner[display_name]</a>)</td>
	</tr>
	<tr>
<td colspan='2'>";
while ($items = mysql_fetch_array($getitems)) {
$itempic = mysql_fetch_array(mysql_query("SELECT * FROM `items2` WHERE `id`='$items[item_id]'"));

echo "<img src='../images/user_images/opg_1/items/item_$items[item_id].gif' border='0'><br /><b>Name:</b> $itempic[item_name]<br /><b>Description:</b>  $itempic[item_desc]<br />";

}
$cp = $getofferid[cp];
$offeredon = mysql_query("SELECT * FROM `trade_items` WHERE `trade_id`='$view[trade_id]'");
echo "CP Offered: $cp</td>
	</tr>
	                <tr>
<td bgcolor='#eeeeee' colspan='2'><b>Items offered on</b></td>
                                <tr>
<td>";
while ($offereditems = mysql_fetch_array($offeredon)) {
$itemp = mysql_fetch_array(mysql_query("SELECT * FROM `items2` WHERE `id`='$offereditems[item_id]'"));

echo "<img src='../images/user_images/opg_1/items/item_$offereditems[item_id].gif' border='0'><br /><b>Name:</b> $itemp[item_name]<br /><b>Description:</b>  $itemp[item_desc]<br />";
}

echo "                             </td>  </tr>

	<tr>
<td colspan='2'><center><input type='submit' value='Cancel this offer!' name='cancel_offer'></center>
<input type='hidden' name='tradedid' value='$getofferid[trade_id]'><input type='hidden' name='item_id' value='$getofferid[item_id]'>";

echo "</td>
	</tr>
</table>
<br /><br /><br />
</form>
";
}

if ($_POST['cancel_offer']) {
$tradedid = $_POST['tradedid'];
$item_id = $_POST['item_id'];
$delete = mysql_query("SELECT * FROM `trade_offers` WHERE `user_id`='$userid'");
while ($trade = mysql_fetch_array($delete)) {
mysql_query("DELETE FROM `trade_offers` WHERE `trade_id`='$tradedid' AND `user_id`='$userid'");
mysql_query("UPDATE `members2` SET `points`=points+$cp WHERE `id`='$userid'");
mysql_query("UPDATE `usersitems2` SET `trading`='no' WHERE `item_id`='$trade[item_id]'");
}
die(header(error("myoffers.php","Trade deleted successfully!")));
}

?>

Link to comment
https://forums.phpfreaks.com/topic/139230-solved-time-question/
Share on other sites

was wondering is there anyway i can pull up those offers based on newest time put into the database

 

Order by the time?

 

so if it has been there for fifteen minutes it will not allow you to cancel the offer

 

Compare the time with now and see if 15 minutes has passed?

 

After 3000 posts, i would have thought you'd have realised it might help to post some relevant code.

 

Link to comment
https://forums.phpfreaks.com/topic/139230-solved-time-question/#findComment-728245
Share on other sites

No.

 

$myoffers = mysql_query("SELECT DISTINCT(trade_id), item_id, user_id, cp  FROM `trade_offers` WHERE `user_id`='$userid' LIMIT 0,1");

 

$myoffers is a mysql result resource. Apart from anything else, you'll need to extract the relevant data out of it first. Even then, you'll need to compare the current time with the time the offer was made. How you do that will depend on what format the data is in.

Link to comment
https://forums.phpfreaks.com/topic/139230-solved-time-question/#findComment-728263
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.