技術提供:Blogger.

創意網頁設計,響應式網頁,部落格版型,資料庫,購物車,Bootstrap,RWD,html,css,php,jquery,MySQL,專營綠茶,紅茶,高山凍頂烏龍,阿里山杉林溪梨山大禹嶺茶及茶葉罐杯壺禮盒批發零售,兼營艋舺快遞,汽機車外送,中央果菜市場,環南市場,迪化街等地代購採買及各項代理服務! 孟甲服務專線:0952-916626
E-mail:roberchen3@gmail.com


控制產品庫存量的php語法

php語法:
<?php
   $colname_web_shop2017 = "-1";
if (isset($_GET['p_id'])) {
  $colname_web_shop2017 = $_GET['p_id'];
}
mysql_select_db($database_conn_web, $conn_web);
$query_web_shop2017 = sprintf("SELECT shop2.p_id, shop2.p_name, shop2.p_price, shop2.p_open, shop2.p_pic, shop2.inventory,  orderlist.p_name,orderlist.odlist_ok, orderlist.odlist_qty, SUM(  `orderlist`.`odlist_qty` ) AS orderlistNum ,shop2.inventory AS inventory , orderlist.odlist_ok AS odlist_ok ,orderlist.odlist_qty AS odlist_qty
FROM shop2
LEFT JOIN orderlist ON shop2.p_name = orderlist.p_name  and  orderlist.odlist_ok='y'
GROUP BY  `orderlist`.`odlist_ok` ,  `shop2`.`p_id` , `shop2`.`p_name` ,  `orderlist`.`p_name`
HAVING  p_id = %s ", GetSQLValueString($colname_web_shop2017, "int"));
$web_shop2017 = mysql_query($query_web_shop2017, $conn_web) or die(mysql_error());
$row_web_shop2017 = mysql_fetch_assoc($web_shop2017);
$totalRows_web_shop2017 = mysql_num_rows($web_shop2017);//段落

?>

<?php
$a=$row_web_shop2017['inventory'];
$b=$row_web_shop2017['orderlistNum'];
$c=$row_web_shop2017['op_name'];
$d=$row_web_shop2017['odlist_ok'];

?>



內文:
 <?php if ($b == NULL    ){ ?>
 已購數量 <?php echo 0 ?>
 <?php } // Show if recordset not empty ?>

  <?php if ($b !== NULL   ){ ?>
  已購數量 <?php echo $b ?>
 <?php } // Show if recordset not empty ?>


<?php if ($b == NULL  ){ ?>
  &nbsp;&nbsp;&nbsp;庫存 <?php echo $a; ?>

 <?php } // Show if recordset not empty ?>

 <?php if ($b !== NULL  and $a-$b>=0){ ?>
  &nbsp;&nbsp;&nbsp;庫存 <?php echo $a-$b; ?>

  <?php } elseif ($b !== NULL  and $a-$b<0){ ?>
   &nbsp;&nbsp;&nbsp;庫存 <?php echo 0 ?>
 <?php } // Show if recordset not empty ?>



"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

文章點閱率及瀏覽量的php語法

php語法文章點擊率、點閱率如下

先新增一個 updatehits_news.php檔案填入下面語法
<?php require_once('Connections/conn_myweb.php'); ?>//連結資料庫

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }



  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);



  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;  

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}



if ((isset($_GET['p_id'])) && ($_GET['p_id'] != "")) {

  $deleteSQL = sprintf("update  shop2 set blog_hits=blog_hits+1 WHERE p_id=%s",

                       GetSQLValueString($_GET['p_id'], "int"));



  mysql_select_db($database_conn_myweb, $conn_myweb);

  $Result1 = mysql_query($deleteSQL, $conn_myweb) or die(mysql_error());



  $deleteGoTo = "news_detial.php?p_id=" . $row_Recordset1['p_id'] . "";

  if (isset($_SERVER['QUERY_STRING'])) {

    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";

    $deleteGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $deleteGoTo));

}



$colname_Recordset1 = "-1";

if (isset($_GET['p_id'])) {

  $colname_Recordset1 = $_GET['p_id'];

}

mysql_select_db($database_conn_myweb, $conn_myweb);

$query_Recordset1 = sprintf("SELECT * FROM shop2 WHERE p_id = %s", GetSQLValueString($colname_Recordset1, "int"));

$Recordset1 = mysql_query($query_Recordset1, $conn_myweb) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

?>

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...