[問題]公會&商店街&銀行(有關於時間)

WOG設定安裝教學

版主: 涅魂, 簫哥

頭像
~木林森~
 
文章: 446
註冊時間: 2005-01-20 12:28 pm
來自: 澎湖的某一處

文章~木林森~ » 2006-06-04 12:41 pm

商店街存貨部分我已經完成了。
只要d_store_top為0的物品沒有存貨數量限制,在商店街中存貨會顯示"--"。
請大家幫忙測試看看有沒有錯誤或是哪裡能改得更好。
在資料庫中輸入下列語法 寫:ALTER TABLE `wog_df` ADD `d_store` smallint(3) unsigned NOT NULL default '0',
ADD `d_store_top` smallint(3) unsigned NOT NULL default '0',
ADD `d_uptime` int(10) unsigned NOT NULL default '0',
ADD `d_uplasttime` int(10) unsigned NOT NULL default '0';

wog_act_shop.php
wog.js


龜速吸收PHP知識中...
"新"[團結就是力量論壇]登場!歡迎大家加入
WOG Only v2.08 + else Mod (簡單的架設結合許多優秀外掛的WOG)


涅魂
 
文章: 4463
註冊時間: 2004-01-04 11:17 am
來自: Taiwan
性別: 男生

文章涅魂 » 2006-06-04 8:12 pm

shop()中
代碼: 選擇全部
$d=$DB_site->query("SELECT d_id,d_store,d_store_top,d_uptime,d_uplasttime FROM wog_df where d_uplasttime<>0 and d_uplasttime < ".time()."-d_uptime");
while($ds=$DB_site->fetch_array($d)){
$DB_site->query_first("UPDATE wog_df SET d_store=d_store+1,d_uplasttime=".time()." WHERE d_id=$ds[d_id] and d_store_top>d_store and d_uplasttime < ".time()."-".$ds[d_uptime]);
}

改成這樣就可以了,不用取出來再更新
代碼: 選擇全部
$DB_site->query_first("UPDATE wog_df SET d_store=d_store+1,d_uplasttime=".time()." WHERE  d_store_top>d_store and [color=red]d_uplasttime < ".time()."-d_uptime[/color]");


buy()中
代碼: 選擇全部
for($i=0;$i<count($_POST["adds"]);$i++)
{
$d=$DB_site->query_first("SELECT d_store,d_name FROM wog_df where d_id=".$_POST["adds"][$i]);
if($d[d_store]==0){
alertWindowMsg($d[d_name]."的存貨量不足");
}

可以換個方式來寫來把回圈拆掉減少程式的執行次數
代碼: 選擇全部
$adds=implode(",",$_POST['adds']);
$check=$DB_site->query_first("SELECT d_name FROM wog_df WHERE d_id in ($adds) AND d_store <= 0 LIMIT 1");
if(!empty($check[0]))
{
alertWindowMsg($check[d_name]."的存貨量不足");
}


而這邊
代碼: 選擇全部
for($i=0;$i<count($_POST["adds"]);$i++)
{
$DB_site->query("update wog_df set d_store=d_store-1 where d_id=".$_POST["adds"][$i]);
}

根據地二個修改的話可以再簡化
代碼: 選擇全部
$DB_site->query("update wog_df set d_store=d_store-1 where d_id in ($adds)");

而wog.js沒有什麼大問題…



頭像
~木林森~
 
文章: 446
註冊時間: 2005-01-20 12:28 pm
來自: 澎湖的某一處

文章~木林森~ » 2006-06-05 6:02 pm

成功了... :)
感謝涅大的教導啊~ :oops:


龜速吸收PHP知識中...
"新"[團結就是力量論壇]登場!歡迎大家加入
WOG Only v2.08 + else Mod (簡單的架設結合許多優秀外掛的WOG)

頭像
kelyiu3000
 
文章: 95
註冊時間: 2004-08-05 7:35 pm

文章kelyiu3000 » 2006-06-05 7:38 pm

木林森 大大 可不可以告之 wog.js 改了那裡好嗎..?



頭像
~木林森~
 
文章: 446
註冊時間: 2005-01-20 12:28 pm
來自: 澎湖的某一處

文章~木林森~ » 2006-06-05 10:40 pm

~木林森~ 寫:wog.js

紅字部分


龜速吸收PHP知識中...
"新"[團結就是力量論壇]登場!歡迎大家加入
WOG Only v2.08 + else Mod (簡單的架設結合許多優秀外掛的WOG)

上一頁

回到 精華區

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 6 位訪客

cron