Hi all,i'm wondering how does the discount system works.I.e i want the product to be discounted only for a several days...From 11/10/09 till 10/13/09..Are there any articles about it?Thanks a lot guys..
discount from date to date
Started by yonghan, Nov 10 2009 08:11 PM
2 replies to this topic
#1
Posted 10 November 2009 - 08:11 PM
|
|
|
#2
Posted 11 November 2009 - 02:52 AM
Heres a display for it.
Require a login? Older members can probly improve my code though TBH.
I could be well off the mark, only started to do OOP so just wait till the more advanced members have a look.
Still getting to grips with PHP myself but i hope this works.
Will edit it later.
<?
class products{
function GetProduct( $productid ) {
$query = "
SELECT productid, name, info, discountbefore, price, discountafter FROM `products`
WHERE
`productid` = '". $productid ."'
LIMIT 1;
";
return $query; //Return the query string
}
}
class DisplayProduct extends products
{
function displayproduct( $query )
{
$today = date("d/m/y"); //Current date in day/month/year format
$discountprice == $this->price/10*9;
echo "Product: ". $this->name ."";
echo "Product Info: ". $this->info ."";
if($this->discountafter>=$today&&$this->discountbefore<=$today)
{
echo"Discount on this item!";
echo"$discountprice";
}
}
$test = new DisplayProduct;
$test->GetProduct = '645345';
$test->displayproduct();
?>
Require a login? Older members can probly improve my code though TBH.
I could be well off the mark, only started to do OOP so just wait till the more advanced members have a look.
Still getting to grips with PHP myself but i hope this works.
Will edit it later.
Edited by Overload, 11 November 2009 - 04:10 AM.
#3
Posted 11 November 2009 - 04:17 AM
Thanks a lot..


Sign In
Create Account


Back to top









