技術提供:Blogger.

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


生活實用網站

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

控制產品庫存量的php語法

以下是控制產品庫存量多少的php語法


先新增一個 inventory.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 inventory=inventory-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...

文章點閱率及瀏覽量的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...

讓iframe自動調整高度

讓iframe自動調整高度

找了好幾個方法,就以這個方法簡單又有效~~

首先,加入iframe的語法。
<iframe src="./source"(欲連結的網頁) name="mainframe" width="98%" 
marginwidth="0" marginheight="0" scrolling="No" 
frameborder="0" id="mainframe" margin-left="20" ></iframe>

在到欲連結的網頁裡,在head下面加入以下程式碼。
<head>  
   <script>
      function resize(){
       parent.document.getElementById("mainframe").height=document.body.scrollHeight;    
     }
   </script>
</head>

並在body裡加入:
<body onload="resize();" > 

這樣就可以嚕~~

還有另一個方法也不錯。只要在同一個檔案內編寫就好。在有iframe的頁面的head之下加入以下程式碼。
<script type="text/javascript">
function SetCwinHeight(){
var iframeid=document.getElementById("iframeid"); //iframe id
if (document.getElementById){
   if (iframeid && !window.opera){
   if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight){
   iframeid.height = iframeid.contentDocument.body.offsetHeight;
   }else if(iframeid.Document && iframeid.Document.body.scrollHeight){
   iframeid.height = iframeid.Document.body.scrollHeight;
   }
   }
}
}
</script>

iframe內加入onload="Javascript:SetCwinHeight()"
<iframe src="./NEWS" name="mainframe" width="98%" 
height="300" marginwidth="0" marginheight="0" 
onload="Javascript:SetCwinHeight()" 
 scrolling="No" frameborder="0" 
id="mainframe" margin-left="20" ></iframe>

因為我的iframe是包在contentRight裏,若contentRight的高度設為自動,則contentRight一開始的高度會很小,所以將contentRight 設一個 min-height:700px 就可以嚕。
~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

室內設計 101時尚舍 happy玩家 魔法巫 孟甲部落格 孟氏洋行 AMCT 骨節 雅弈