Jump to content

discount from date to date

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
yonghan

yonghan

    Learning Programmer

  • Members
  • PipPipPip
  • 99 posts
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..

#2
Overload

Overload

    Newbie

  • Members
  • PipPip
  • 16 posts
Heres a display for it.
<?

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
yonghan

yonghan

    Learning Programmer

  • Members
  • PipPipPip
  • 99 posts
Thanks a lot..