技術提供:Blogger.

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


顯示具有 php&mysql 標籤的文章。 顯示所有文章
顯示具有 php&mysql 標籤的文章。 顯示所有文章

php抽獎程式 亂數隨機抽獎

index.php:
<form id="form1" name="form1" method="post" action="">
總數:
<input type="text" name="total" id="total" />
<br />
筆數:
<input type="text" name="count" id="count" />
<br />
排除:
<input name="except" type="text" id="except"  />
<br />
<input type="submit" name="button" id="button" value="送出" />
</form>
<hr>
<?php
if(isset($_POST['total']) && isset($_POST['count'])){
$POST_total = $_POST['total'];
$POST_count = $_POST['count'];
$POST_except = $_POST['except'];

$Rand = Array(); //定義陣列
$count = $POST_count ; //共產生幾筆

if(isset($_POST['except'])){
/*文字轉陣列-排除名單*/
$Rand = explode(",",$POST_except);
}

while($count > 0){
$randval = mt_rand(1,$POST_total); //取亂數

if (!in_array($randval, $Rand)) {
$count--;
$Rand[] = $randval; //若無重復則 將亂數塞入陣列
echo $randval."<br>";
}
}
}
?>


~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

資料庫 SQL WHERE BETWEEEN ID 語法

SELECT * FROM shop2 WHERE (p_open = 'Y') and (shop_id between 1 and 3)  ORDER BY p_date DESC
從shop2資料表選取全部資料,且符合產品資料開放及產品分類id介於1~3之間的產品,依照日期遞減。

SELECT * FROM shop2 WHERE (p_open = 'Y') and (shop_id in (1,3,5))  ORDER BY p_date DESC
從shop2資料表選取全部資料,且符合產品資料開放及產品分類id在(1,3,5)的產品,依照日期遞減。

SELECT * FROM shop2 WHERE (p_open = 'Y') and (shop_id >=1 and shop_id<=5)  ORDER BY p_date DESC
從shop2資料表選取全部資料,且符合產品資料開放及產品分類id介於1~5之間的產品,依照日期遞減。

SELECT * FROM shop2 WHERE (p_open = 'Y') and (shop_id in (1,3,5)) AND (shop_id !=5)  ORDER BY p_date DESC
從shop2資料表選取全部資料,且符合產品資料開放及產品分類id介於1~5之間的產品,且產品分類id不等於5,依照日期遞減。

SELECT * FROM shop2 WHERE (p_open = 'Y') and (p_date>='2016-01-26' and p_date<='2016-02-03') ORDER BY p_date DESC
從shop2資料表選取全部資料,且符合產品資料開放及日期時間介於2016-01-26 和 2016-02-03之間的產品,依照日期遞減。

~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

WordPress的自訂模板功能,讓首頁搭配上自行客製的模板

新增頁面模板

1.首先,先在佈景的資料夾中,新增一個php檔案(名稱自訂)。接著將檔案打開,在檔案內先加入下面的程式碼:
<?php
/*
Template Name: 客製首頁
*/
?>
這一個PHP檔案就叫他welcome.php,之後教學會使用到。
再來,到WordPress控制台→頁面→新增頁面,標題打「首頁」即可,內容留空。在右邊的頁面屬性中,會看到模板選單中有一個「客製首頁」,要選擇客製首頁。(按發表)
2.將welcome.php的內容修改為:
<?php
/*
Template Name: 客製首頁
*/
echo "開始客製!哇,這真的太棒了~想放什麼內容就放在裡面,也可以任意使用WP的函式、佈景函式了!";
?>

3.設定此頁面為首頁
這時候你會說:我要顯示在首頁,不是在分頁,然後讓Blog文章在分頁顯示。OK,我們先新增一個頁面,頁面名稱為Blog。(使用預設模板,內容不用打,直接按發佈。)
4.在WordPress的設定中就有選項,在控制台→「設定」→「閱讀」。
將首頁顯示選擇為靜態頁面,「首頁」選擇一開始新增的「首頁」頁面,文章頁面選擇剛剛新增的「Blog」。(記得按下儲存)
5.將首頁顯示選擇為靜態頁面,「首頁」選擇一開始新增的「首頁」頁面,文章頁面選擇剛剛新增的「Blog」。(按下儲存)
~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

[free joomla template]Joomla! 免費佈景下載

佈景商免費佈景數量下載網址
joomlaxtc1joomlxtc free
shape54shape5 free
rocket theme6rocket free(篩選free)
gavick3gavick free
joomlashine14joomlashine free
joomlaworks2joomlaworks free
~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

[ PHP ] –去除HTML標籤及替換文字樣式效果語法

<?php
     //去除HTML標籤,先找到關鍵字第一次出現位置,並將字元位置儲存在自訂變數$start_place中
     $start_place=mb_strrpos(strip_tags($row_web_search['p_content']),$_GET['keyword'],"UTF-8");
     //希望關鍵字出現在商品簡介中央位置,所以起始字元位置-50(因為指定截取100個字元)
     $start_place=$start_place-50;
     //去除p_content欄位中,商品介紹文案的HTML及PHP語法標籤後,指定截取出100個字元後,儲存給變數$p_content
     $p_content=mb_substr(strip_tags($row_web_search['p_content']),$start_place,100,"UTF-8");
     //改用eregi_replace函數為搜尋結果中的關鍵字內容,替換文字樣式效果
     $p_content=eregi_replace($_GET['keyword'],"<font color='#ff0000' style='background:#ffff00'>".$_GET['keyword']."</font>",$p_content);
     //輸出最後效果
     echo $p_content;
?>
若要保留Html某標籤可用
<?php
$showStr="你學<strong>PHP</strong><br>我學
<strong>PHP</strong><br/>大家來學<strong>PHP</strong>";
echo $showStr."<hr/>"
echo strip_tags($showStr,'<br>');
?>

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

php解決不斷行連續數字及英文字母撐破版面語法 自動去除html語法

解決不斷行連續數字及英文字母與法:
<div style="word-break:break-all"></div>

自動去除html語法
 <?php  echo strip_tags($row_web_shop2['p_content']); ?>
加入strip_tags( )


~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

[ PHP ] 歐付寶金流串接範例

假設你的主機網址為 http://192.168.1.1
1.下載歐付寶 SDK PHP版本
https://github.com/allpay/PHP
開啟頁面後 點選右方 Download ZIP
下載後本機端解壓縮 開啟資料夾 AioSDK
複製該資料夾中的 AllPay.Payment.Integration.php
到你的主機中
例如放在這裡
http://192.168.1.1/AllPay.Payment.Integration.php
2.產生訂單 order_add.php
程式碼如下
<?php
header("Content-Type:text/html; charset=utf-8");
include_once('./AllPay.Payment.Integration.php');
/*產生訂單範例*/
try
{
$oPayment = new AllInOne();
/* 服務參數 */
$oPayment->ServiceURL ="http://payment-stage.allpay.com.tw/Cashier/AioCheckOut ";
$oPayment->HashKey = "5294y06JbISpM5x9";//這是測試帳號專用的不用改它
$oPayment->HashIV = "v77hoKGq4kWxNNIS";//這是測試帳號專用的不用改它
$oPayment->MerchantID = "2000132";//這是測試帳號專用的不用改它
$time=time();
/* 基本參數 */
$oPayment->Send['MerchantTradeNo'] = $time;//這邊是店家端所產生的訂單編號
$oPayment->Send['MerchantTradeDate'] = date("Y/m/d H:i:s");
$oPayment->Send['TotalAmount'] = "1000";//付款總金額
$oPayment->Send['TradeDesc'] = "年終慶大特賣";//交易敘述
$oPayment->Send['ChoosePayment'] = PaymentMethod::ALL;//付款方式 這邊是開啟所有付款方式讓消費者自行選擇
$oPayment->Send['ReturnURL'] = "http://192.168.1.1/return.php";//請填入你主機要接受訂單狀態回傳的程式名稱 記住 該網址需能對外
$oPayment->Send['IgnorePayment'] ="Alipay";//把不的付款方式取消掉

// 加入選購商品資料。
array_push($oPayment->Send['Items'], array('Name' =&gt; "產品名稱", 'Price' =&gt; (int)"100", 'Currency' =&gt; "元", 'Quantity' =&gt; (int) "1", 'URL' =&gt; "http://TEST.com.tw/"));

/* 產生訂單 */
$oPayment->CheckOut();
/* 產生產生訂單 Html Code 的方法 */
$szHtml = $oPayment->CheckOutString();

}
catch (Exception $e)
{ // 例外錯誤處理。
throw $e;
}
?>

在網址列輸入 http://192.168.1.1/order_add.php
應該就會跳到歐付寶的付款頁面
我們選擇 信用卡付款
信用卡資料填入 (以下皆為 歐付寶提供的 測試資料)
卡號 4311-9522-2222-2222
安全碼 222
到期年月 月隨便填 年也是但要選大於今年
手機請填你真實的手機 等一下要收驗證碼用的
按送出後 會跳到下一頁請你填入手機驗證碼 請等約一分鐘就會收到 驗證碼簡訊
填入驗證碼後 即付款完成
3.查詢訂單是否存在
先登入測試的歐付寶廠商管理後台
http://vendor-stage.allpay.com.tw/Home/Index
帳號 StageTest
密碼 test1234
登入後 點選左方選單 一般訂單查詢->全方位金流訂單
開啟該頁面後 查詢條件 付款方式 請選擇信用卡付款 然後按 查詢
接著在下面應該就能看到剛剛已經付款完成的訂單紀錄
4.接收訂單狀態程式 http://192.168.1.1/return.php
程式碼如下
<?php
header("Content-Type:text/html; charset=utf-8");
include_once('./AllPay.Payment.Integration.php');
try{
$oPayment = new AllInOne();
/* 服務參數 */
$oPayment->HashKey = "5294y06JbISpM5x9";
$oPayment->HashIV = "v77hoKGq4kWxNNIS";
$oPayment->MerchantID = "2000132";
/* 取得回傳參數 */
$arFeedback = $oPayment->CheckOutFeedback();
/* 檢核與變更訂單狀態 */
if (sizeof($arFeedback) &gt; 0) {
foreach ($arFeedback as $key =&gt; $value) {
switch ($key)
{
/* 支付後的回傳的基本參數 */
case "MerchantID": $szMerchantID = $value; break;
case "MerchantTradeNo": $szMerchantTradeNo = $value; break;
case "PaymentDate": $szPaymentDate = $value; break;
case "PaymentType": $szPaymentType = $value; break;
case "PaymentTypeChargeFee": $szPaymentTypeChargeFee = $value; break;
case "RtnCode": $szRtnCode = $value; break;
case "RtnMsg": $szRtnMsg = $value; break;
case "SimulatePaid": $szSimulatePaid = $value; break;
case "TradeAmt": $szTradeAmt = $value; break;
case "TradeDate": $szTradeDate = $value; break;
case "TradeNo": $szTradeNo = $value; break;
default: break;
}
}
// 其他資料處理。
print '1|OK';
} else {print '0|Fail';}
}
catch (Exception $e){
// 例外錯誤處理。
print '0|' . $e->getMessage();
}

?>


~引用自混水摸魚網站,文章若有侵權,請來信告知,我們會盡快處理~

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

不間斷的跑馬燈語法搭配php程式碼

<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>孟甲商行</title>
<style type="text/css">
#myDiv {
                overflow: hidden;
                width: 350px;
                background-color: red;
        }
       
        #myDiv img {
                border: 1px solid;
                width: 80px;
        }
</style>
</head>

<body>
<div id="myDiv">
        <table>
        <tr>
                <td id="pic1">
                        //可在紅色字區域將他替換為程式碼
<table>
                        <tr>
                                <td><img src="0.gif" /></td>
                                <td><img src="1.gif" /></td>
                                <td><img src="2.gif" /></td>
                                <td><img src="3.gif" /></td>
                                <td><img src="4.gif" /></td>
                                <td><img src="5.gif" /></td>
                                <td><img src="6.gif" /></td>
                                <td><img src="7.gif" /></td>
                        </tr>
                        </table>
//可在紅色字區域將他替換為程式碼
                </td>
                <td id="pic2"></td>
        </tr>
        </table>
</div>
</body>

<script type="text/javascript">
<!--
        //變數Speed為設定捲軸的速度用 越小越快
        var Speed=1;
        //接受setInterval所回傳的值
        var timer;
        //取得myDiv的參考用的變數
        var myDiv = document.getElementById("myDiv");
        //取得pic2的參考用的變數
        var pic2= document.getElementById("pic2");
        //pic2innerHTML等於pic1innerHTML
        pic2.innerHTML=document.getElementById("pic1").innerHTML;
        //用來捲動myDiv捲軸用的主程式
        function picMarquee(){
                //pic2的寬小於myDivscrollLeft,表示捲軸已經過了第一行
                //所以讓DivscrollLeft再回到原來的位置;反之 則繼續往右跑
                if(pic2.offsetWidth - myDiv.scrollLeft <= 0){
                        myDiv.scrollLeft = 0;
                }else{
                        myDiv.scrollLeft++;
                }
        }
        //Speed毫秒就執行一次pciMarquee()
        timer=setInterval(picMarquee,Speed);
        //當滑鼠在myDiv上時 就停止捲動
        myDiv.onmouseover=function(){
                clearInterval(timer);
        }
        //當滑鼠離開myDiv上時 就繼續往右捲動
        myDiv.onmouseout=function(){
                timer=setInterval(picMarquee,Speed);
        }
//-->
</script>
</html>
<!--Hinet廣告用-->
<script type="text/javascript">
<!--
        //先用Open物件來替代window.open()
        var Open = window.open;
        //覆寫window.open()變成回傳window本身
        window.open = function(){return window;};
//-->

</script>
~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~


"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

php檔案上傳下載功能及語法

<?php
//取得目前路徑
$fileDir = getcwd();
//執行刪除動作
if(isset($_GET["action"])&&$_GET["action"]=="delete"){
unlink($_GET["file"]);
$fileDir =pathinfo($_GET["file"],PATHINFO_DIRNAME);
//重新轉頁到目前目錄中
header("Location: ?dir=".$fileDir);
}
//執行上傳動作
if(isset($_GET["action"])&&$_GET["action"]=="upload"){
if($_FILES["upload"]["error"]==0){
move_uploaded_file($_FILES["upload"]["tmp_name"], $_POST["dir"]."//".$_FILES["upload"]["name"]);
}
//重新轉頁到目前目錄中
header("Location: ?dir=".$_POST["dir"]);
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>檔案管理</title>
</head>
<body>
<?php
//若有URL參數dir,其值即為目前路徑
if(isset($_GET["dir"])&&$_GET["dir"]!=""){
$fileDir = $_GET["dir"];
}
//目前路徑上一層路徑
$fileUplevel = dirname($fileDir);
//取得目前路徑中的內容
$fileResource = scandir($fileDir);
echo '<table width="500" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000">';
//顯示目前路徑
echo '<tr><td bgcolor="#FAFAFA"colspan="3">目前路徑:'.$fileDir.'</td></tr>';
echo '<tr><td bgcolor="#FAFAFA"colspan="3" align="center">';
//設定URL參數action為upload
echo '<form action="?action=upload" method="post" enctype="multipart/form-data" name="form1" id="form1">';
//將上一層路徑帶進連結的URL參數dir中
echo '上傳檔案 <input type="file" name="upload" style="height:20px" />';
echo '<input type="submit" name="button" style="height:20px" value="送出" />';
echo '<input name="dir" type="hidden" id="dir" value="'.$fileDir.'" /></form>';
echo '<tr><td bgcolor="#FAFAFA">名稱</td><td bgcolor="#FAFAFA" width="120" align="center">檔案大小</td><td bgcolor="#FAFAFA" width="80" align="center">功能</td></tr>';
//顯示資料夾內容
foreach($fileResource as $fileName){
if(is_dir($fileDir.'\\'.$fileName)){
//不顯示相對路徑「.」及「..」
if($fileName != "." && $fileName !=".."){
//顯示資料夾,並設定該資料夾的路徑帶進連結的URL參數dir中
echo '<tr><td bgcolor="#FAFAFA" width="300"><a href="?dir='.$fileDir.'//'.$fileName.'">&lt;'.$fileName.'&gt;</a></td>';
echo '<td bgcolor="#FAFAFA" width="120">&nbsp;</td><td bgcolor="#FAFAFA" width="80">&nbsp;</td></tr>';
}
}
}
//顯示檔案的內容
foreach($fileResource as $fileName){
if(is_file($fileDir.'\\'.$fileName)){
//計算檔案大小
$fsize = filesize($fileDir.'\\'.$fileName);
//顯示檔案名稱
echo '<tr><td bgcolor="#FAFAFA" width="300">'.$fileName.'</td>';
//顯示檔案大小,並以千位符號格式化顯示
echo '<td bgcolor="#FAFAFA" width="120" align="right">'.number_format($fsize).' bytes</td>';
//在刪除文字上加上連結,並設定該資料夾的路徑帶進連結的URL參數dir、參數action為delete
echo '<td bgcolor="#FAFAFA" width="80" align="center"><a href="?file='.$fileDir.'\\'.$fileName.'&action=delete">刪除</a></td></tr>';
}
}
echo '</table>';
?>




<div style="margin-top:100px;">
<?php
//若有URL參數dir,其值即為目前路徑
if(isset($_GET["dir"])&&$_GET["dir"]!=""){
$fileDir = $_GET["dir"];
}
//目前路徑上一層路徑
$fileUplevel = dirname($fileDir);
//取得目前路徑中的內容
$fileResource = scandir($fileDir);
echo '<table width="500" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#000000">';
//顯示目前路徑
echo '<tr><td bgcolor="#FAFAFA"colspan="3">目前路徑:'.$fileDir.'</td></tr>';
echo '<tr><td bgcolor="#FAFAFA"colspan="3" align="center">';
//設定URL參數action為upload

echo '<tr><td bgcolor="#FAFAFA">名稱</td><td bgcolor="#FAFAFA" width="120" align="center">檔案大小</td><td bgcolor="#FAFAFA" width="80" align="center">功能</td></tr>';
//顯示資料夾內容
foreach($fileResource as $fileName){
if(is_dir($fileDir.'\\'.$fileName)){
//不顯示相對路徑「.」及「..」
if($fileName != "." && $fileName !=".."){
//顯示資料夾,並設定該資料夾的路徑帶進連結的URL參數dir中
echo '<tr><td bgcolor="#FAFAFA" width="300"><a href="?dir='.$fileDir.'//'.$fileName.'">&lt;'.$fileName.'&gt;</a></td>';
echo '<td bgcolor="#FAFAFA" width="120">&nbsp;</td><td bgcolor="#FAFAFA" width="80">&nbsp;</td></tr>';
}
}
}
//顯示檔案的內容
foreach($fileResource as $fileName){
if(is_file($fileDir.'\\'.$fileName)){
//計算檔案大小
$fsize = filesize($fileDir.'\\'.$fileName);
//顯示檔案名稱
echo '<tr><td bgcolor="#FAFAFA" width="300">'.$fileName.'</td>';
//顯示檔案大小,並以千位符號格式化顯示
echo '<td bgcolor="#FAFAFA" width="120" align="right">'.number_format($fsize).' bytes</td>';
//在刪除文字上加上連結,並設定該資料夾的路徑帶進連結的URL參數dir、參數action為下載
echo '<td bgcolor="#FAFAFA" width="80" align="center"><a href="po/'.$fileName.'" target="1_blank">下載</a></td></tr>';
}
}
echo '</table>';
?>
</div>
</body>
</html>


~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~

"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...

php 點閱次數統計及點閱率語法

點閱次數:{BlogRec.blog_hits}作法
1.先在資料庫blog_msg資料表新增一個blog_hits欄位名稱  
2.先新增一個updatehits.php/伺服器按加 / 點刪除紀錄
3.
if ((isset($_GET['blog_no'])) && ($_GET['blog_no'] != "")) {
  $deleteSQL = sprintf("DELETE FROM blog_msg WHERE blog_no=%s", GetSQLValueString($_GET['blog_no'], "int"));

  mysql_select_db($database_blogConn, $blogConn);
  $Result1 = mysql_query($deleteSQL, $blogConn) or die(mysql_error());

  $deleteGoTo = "blognew.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $deleteGoTo));
}
DELETE FROM blog_msg WHERE blog_no=%s改成下面語法
update  blog_msg set blog_hits=blog_hits+1 WHERE blog_no=%s

4.blog.php
<h5 style="font-size:20px;color:black;text-align:left"><a style="text-decoration: none;"  href="updatehits.php?blog_no=<?php echo $row_BlogRec['blog_no']; ?>"><?php echo $row_BlogRec['blog_subject']; ?></a> [<?php echo $row_BlogRec['blog_postdate']; ?>]<span style="font-size:14px;"> 點閱次數:<?php echo $row_BlogRec["blog_hits"]+300;?></span></h5>

5.當按下blog.php主題連結到updatehits.php更新資料庫blog_hits+1後馬上跳轉到blognew.php

~歡迎轉載,但請註明來源網站名稱和網址,文章若有侵權,請來信告知,我們會盡快處理~


"你是獵人還是獵物?"

Related Posts Plugin for WordPress, Blogger...