<?php
session_start();
?>
<?php error_reporting(0); ?>
<?php
session_start;
include("includes1/db.php");
include("includes1/functions1.php");
$_SESSION ["cart"]++;
if($_REQUEST['command']=='add' && $_REQUEST['productid']>0){
$pid=$_REQUEST['productid']; echo"$pid";
addtocart($pid,1);
header("location:product_summary1.php");
exit();
}
?>
<html>
<body>
<?php
mysql_connect("localhost","root","") or die("Demo is not available, please try again later");
mysql_select_db("agriculture") or die("Demo is not available, please try again later");
if (!empty($_GET['sort']) && $_GET['sort'] == 'PriceAsc') {
$orderby=" ORDER BY price ASC";
}
if (!empty($_GET['sort']) && $_GET['sort'] == 'PriceDesc') {
$orderby=" ORDER BY price DESC";
}
?>
<div class="row-fluid"></div>
<ul class="thumbnails">
<?php
$datestart = '15-12-2016';
$dateend = '16-12-2016';
$product_name= 'product_name';
$discount= 'discount';
$price = 'price';
$data=mysql_query("select * from promotion ".$orderby) or die("select * from promotion"."<br/><br/>
".mysql_error());
while($row=mysql_fetch_array($data)){
?>
<li class="span3">
<div class="thumbnail">
<a href="product_details.html"><img src="themes/images/products/<?php echo $row['productimage']?>" alt=""/></a>
<div class="caption">
<h5><?php echo $row['name']?></h5>
<h5>PROMOTION END : <?php echo $row['dateend']?></h5>
<p> </p>
<h4 style="text-align:center"></i></a> <a class="btn" type="button" value="Add to Cart" onClick="addtocart(<?php echo $row['serial']?>)">Add to <i class="icon-shopping-cart"></i></a>
<a class="btn btn-primary" href="#">RM <?php $date = date ('d-m-y');
if ($date <= $datestart)
{echo $total = $row['price'] - $row['discount']."</br>" ;}
else if ($date <= $dateend)
{echo $row['price'] ."<br/>";}
else
{echo $row['price']."<br/>";
}?></a> /unit</h4>
</div>
</div>
<?php } ?>
</li>
</ul>
</form></div>
</div>
</div>
</div>
</body>
</html>
これは私のプロモーションページコードです。私はデータベースに記入する日付を使用する必要があります。プロモーションの期限が切れた場合、プロモーションの前に価格を価格に変更する必要があります。だから私は、日付の宣伝を宣言し、それを使用する関数を作成します。プロモーション日が終了すると、価格表示が変更されます。カートに追加をクリックすると、価格はプロモーション価格になります。標準価格ではありません。私を助けてください。PHP /動的価格を使用してmysqlからプロモーションの日付を取得する方法
date ('d-m-Y')
へ。 mysql_ ..のすべての機能は償却されました。 –私はmysqliの使い方を知らない。私の発表日tmrw。私はそれについて勉強する時間がありません。 –