1 頁 (共 1 頁)

[問題]RPG資料要如何加入武器防具....

發表於 : 2006-04-23 13:00
Zeans
我想在發表人有武器防具的一些RPG資料

所以自己增加了viewtopic.php

代碼: 選擇全部

'<tr><td><span class="gensmall">左 手:</span></td><td><span class="gensmall">' . $postrow[$i]{RPG_LEFT_HAND} . '</span></td></tr>' . 
'<tr><td><span class="gensmall">右 手:</span></td><td><span class="gensmall">' . $postrow[$i]{RPG_RIGHT_HAND} . '</span></td></tr>' . 
'<tr><td><span class="gensmall">盔 甲:</span></td><td><span class="gensmall">' . $postrow[$i]{RPG_DEFEND} . '</span></td></tr>' . 
'<tr><td><span class="gensmall">腳 部:</span></td><td><span class="gensmall">' . $postrow[$i]{RPG_LEGER} . '</span></td></tr>' .
'<tr><td><span class="gensmall">頭 盔:</span></td><td><span class="gensmall">' . $postrow[$i]{RPG_SAFETY} . '</span></td></tr></table>'; 
都只能顯示左手.右手.....的字而已

武器的名稱都沒有顯示出來

另外我還想加入"人氣指數"
http://202.39.234.25/phpbb/viewtopic.ph ... 7%E6%95%B8

請問哪些地方有錯誤?
煩請指正!!

發表於 : 2006-04-23 20:59
hentaibbc
$postrow[$i]
這個東西是php中的變數

{RPG_LEFT_HAND}
而這個呢!是用$template所指定的東西....
是用在tpl中的...

應該要是$postrow[$i]['xxxxx'];
這樣才對...
而且...還要確定你的$postrow是不是有包括了你要的資料了...

這又要回去看你的$sql取值...

這麼說....能了解嗎???

發表於 : 2006-04-23 21:33
Zeans
我大部分都搞不懂耶
viewtopic.php是改成這樣嗎?

代碼: 選擇全部

'<tr><td><span class="gensmall">左 手:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_left_hand'] . '</span></td></tr>' . 
'<tr><td><span class="gensmall">右 手:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_right_hand'] . '</span></td></tr>' . 
'<tr><td><span class="gensmall">盔 甲:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_defend'] . '</span></td></tr>' . 
'<tr><td><span class="gensmall">腳 部:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_safety'] . '</span></td></tr>' .
'<tr><td><span class="gensmall">頭 盔:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_leger'] . '</span></td></tr></table>'; 
然後尋找

代碼: 選擇全部

'POSTER_RPG_LEVEL'=> $postrow[$i]['rpg_level'], //RPG's by Yoshikawa 
'POSTER_RPG_MEDALS' => $postrow[$i]['rpg_medals'], //RPG's by Yoshikawa 
'POSTER_RPG_CUR_HP' => $postrow[$i]['rpg_cur_hp'], //RPG's by Yoshikawa 
'POSTER_RPG_CUR_MP'=> $postrow[$i]['rpg_cur_mp'], //RPG's by Yoshikawa 
'POSTER_RPG_SPEED'=> $postrow[$i]['rpg_speed'], //RPG's by Yoshikawa 
'POSTER_RPG_ATTACK'=> $postrow[$i]['rpg_attack'], //RPG's by Yoshikawa 
'POSTER_RPG_DEFENSE'=> $postrow[$i]['rpg_defense'], //RPG's by Yoshikawa 
'POSTER_RPG_CUR_EXP'=> $postrow[$i]['rpg_cur_exp'], //RPG's by Yoshikawa 
後面加上

代碼: 選擇全部

	                'POSTER_RPG_LEFT_HAND' => $postrow[$i]['rpg_left_hand'], 
	                'POSTER_RPG_RIGHT_HAND' => $postrow[$i]['rpg_right_hand'], 
                	'POSTER_RPG_DEFEND' => $postrow[$i]['rpg_defend'], 
                	'POSTER_RPG_SAFETY' => $postrow[$i]['rpg_safety'], 
                	'POSTER_RPG_LEGER' => $postrow[$i]['rpg_leger'], 
至於$sql要怎麼去修改呢?

發表於 : 2006-04-23 22:22
hentaibbc
在php檔中
用這樣的方式
$template->assign_vars(array(
"XXXX" => $xxx)
);

然後在對應的tpl檔中
用{XXXX}就可以顯示$xxx的內容...

============================

而$sql怎麼改...
這個請去查書或相關資料吧...

發表於 : 2006-04-24 11:50
心靈捕手
Zeans 寫:我大部分都搞不懂耶
viewtopic.php是改成這樣嗎?

代碼: 選擇全部

'<tr><td><span class="gensmall">左 手:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_left_hand'] . '</span></td></tr>' . 
'<tr><td><span class="gensmall">右 手:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_right_hand'] . '</span></td></tr>' . 
'<tr><td><span class="gensmall">盔 甲:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_defend'] . '</span></td></tr>' . 
'<tr><td><span class="gensmall">腳 部:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_safety'] . '</span></td></tr>' .
'<tr><td><span class="gensmall">頭 盔:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_leger'] . '</span></td></tr></table>'; 
然後尋找

代碼: 選擇全部

'POSTER_RPG_LEVEL'=> $postrow[$i]['rpg_level'], //RPG's by Yoshikawa 
'POSTER_RPG_MEDALS' => $postrow[$i]['rpg_medals'], //RPG's by Yoshikawa 
'POSTER_RPG_CUR_HP' => $postrow[$i]['rpg_cur_hp'], //RPG's by Yoshikawa 
'POSTER_RPG_CUR_MP'=> $postrow[$i]['rpg_cur_mp'], //RPG's by Yoshikawa 
'POSTER_RPG_SPEED'=> $postrow[$i]['rpg_speed'], //RPG's by Yoshikawa 
'POSTER_RPG_ATTACK'=> $postrow[$i]['rpg_attack'], //RPG's by Yoshikawa 
'POSTER_RPG_DEFENSE'=> $postrow[$i]['rpg_defense'], //RPG's by Yoshikawa 
'POSTER_RPG_CUR_EXP'=> $postrow[$i]['rpg_cur_exp'], //RPG's by Yoshikawa 
後面加上

代碼: 選擇全部

	                'POSTER_RPG_LEFT_HAND' => $postrow[$i]['rpg_left_hand'], 
	                'POSTER_RPG_RIGHT_HAND' => $postrow[$i]['rpg_right_hand'], 
                	'POSTER_RPG_DEFEND' => $postrow[$i]['rpg_defend'], 
                	'POSTER_RPG_SAFETY' => $postrow[$i]['rpg_safety'], 
                	'POSTER_RPG_LEGER' => $postrow[$i]['rpg_leger'], 
至於$sql要怎麼去修改呢?
建議您:
比照之前的修改

代碼: 選擇全部

#-----[ 打開 ]-----------------------------------------------------------------------
#
viewtopic.php

#
#-----[ 尋找這一段 ]-----------------------------------------------------------------
#
$sql = "SELECT u.username, u.user_id
	FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
	WHERE p.topic_id = $topic_id

#
#-----[ 在 $sql = "SELECT 後面尋找 ]-------------------------------------------------
#
u.user_allowsmile

#
#-----[ 之後, 加上 ]-----------------------------------------------------------------
#
,u.user_robfail, u.rpg_level, u.rpg_cur_hp, u.rpg_max_hp, u.rpg_cur_mp, u.rpg_max_mp, u.rpg_cur_exp, u.rpg_max_exp, u.rpg_attack, u.rpg_defense, u.rpg_magic, u.rpg_speed, u.rpg_medals
再追加幾個 '欄位' 即可.

代碼: 選擇全部

, u.rpg_left_hand, u.rpg_right_hand, u.rpg_defend, u.rpg_safety, u.rpg_leger

發表於 : 2006-04-24 22:29
Zeans
心靈捕手大大,我已經按照你所說的加上這些

代碼: 選擇全部

, u.rpg_left_hand, u.rpg_right_hand, u.rpg_defend, u.rpg_safety, u.rpg_leger 
但是卻出現下面這樣的錯誤

Could not obtain post/user information.

DEBUG MODE

SQL Error : 1054 Unknown column 'u.rpg_left_hand' in 'field list'

SELECT u.username, u.user_money, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile,u.user_robfail, u.rpg_level, u.rpg_cur_hp, u.rpg_max_hp, u.rpg_cur_mp, u.rpg_max_mp, u.rpg_cur_exp, u.rpg_max_exp, u.rpg_attack, u.rpg_defense, u.rpg_magic, u.rpg_speed, u.rpg_medals, u.rpg_left_hand, u.rpg_right_hand, u.rpg_defend, u.rpg_safety, u.rpg_leger, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM phpbb_posts p, phpbb_users u, phpbb_posts_text pt WHERE p.topic_id = 2 AND pt.post_id = p.post_id AND u.user_id = p.poster_id ORDER BY p.post_time ASC LIMIT 0, 15

Line : 405
File : viewtopic.php

我單純只想把水怪RPG的個人資料上面的左手.右手後面所顯示的東西
圖檔

讓發表人的這個地方也可以顯示出來
圖檔

還請大大指點迷津!!

發表於 : 2006-04-25 11:13
心靈捕手
Zeans 寫:心靈捕手大大,我已經按照你所說的加上這些

代碼: 選擇全部

, u.rpg_left_hand, u.rpg_right_hand, u.rpg_defend, u.rpg_safety, u.rpg_leger 
但是卻出現下面這樣的錯誤

Could not obtain post/user information.

DEBUG MODE

SQL Error : 1054 Unknown column 'u.rpg_left_hand' in 'field list'
抱歉! 我只是針對之前您所做的修改加以判斷,
並沒有深入思考, 以至於出現錯誤. :oops:

建議您:
還原安裝水怪後的 viewtopic.php,
針對您的需求, 重新修改.
如下:
#
#-----[ FIND ]-----
#

代碼: 選擇全部

	$rpgstatus = '<table width="142" cellpadding="0" cellspacing="0" border="0" class="bodyline">' .
			'<tr><td width="35%"><span class="gensmall">職 照:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_medals'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">等 級:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_level'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">H P:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_cur_hp'] . ' / ' . $postrow[$i]['rpg_max_hp'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">M P:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_cur_mp'] . ' / ' . $postrow[$i]['rpg_max_mp'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">經驗值:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_cur_exp'] . ' / ' . $postrow[$i]['rpg_max_exp'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">攻擊力:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_attack'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">防禦力:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_defense'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">魔 力:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_magic'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">速 度:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_speed'] . '</span></td></tr></table>';
#
#-----[ BEFORE, ADD ]-----
#

代碼: 選擇全部

// + 左右手
$righthand = '';
$lefthand = '';

$sql = 'SELECT i.item_name, i.item_position FROM phpbb_rpg_items i, phpbb_rpg_owns o WHERE i.in_which_store = 1 AND i.item_id = o.item_id AND o.user_id = ' . $postrow[$i]['user_id'] . ' ORDER BY i.item_position';
if ( $result = $db->sql_query($sql) )
{
	if ( $row = $db->sql_fetchrow($result) )
	{
		do
		{
			switch ($row['item_position'])
			{
				case 1:
					if ($righthand == '')
					{
						$righthand = $row['item_name'];
					}
					else
					{
						$lefthand = $row['item_name'];
					}
					break;
			}
		}
		while ( $row = $db->sql_fetchrow($result) );
	}
}
// - 左右手
// + 沒光的防具店、水怪的頭盔店、風神的鞋子店
$defend = ''; 
$sql = 'SELECT i.item_name, i.item_position FROM phpbb_rpg_items i, phpbb_rpg_owns o WHERE i.in_which_store = 2 AND i.item_id = o.item_id AND o.user_id = ' . $postrow[$i]['user_id'] . ' ORDER BY i.item_position'; 
if ( $result = $db->sql_query($sql) ) 
{ 
if ( $row = $db->sql_fetchrow($result) ) 
{ 
if ($defend == '') 
{ 
$defend = $row['item_name']; 
} 
} 
} 
$safety = ''; 
$sql = 'SELECT i.item_name, i.item_position FROM phpbb_rpg_items i, phpbb_rpg_owns o WHERE i.in_which_store = 4 AND i.item_id = o.item_id AND o.user_id = ' . $postrow[$i]['user_id'] . ' ORDER BY i.item_position'; 
if ( $result = $db->sql_query($sql) ) 
{ 
if ( $row = $db->sql_fetchrow($result) ) 
{ 
if ($safety == '') 
{ 
$safety = $row['item_name']; 
} 
} 
} 
$leger = ''; 
$sql = 'SELECT i.item_name, i.item_position FROM phpbb_rpg_items i, phpbb_rpg_owns o WHERE i.in_which_store = 5 AND i.item_id = o.item_id AND o.user_id = ' . $postrow[$i]['user_id'] . ' ORDER BY i.item_position'; 
if ( $result = $db->sql_query($sql) ) 
{ 
if ( $row = $db->sql_fetchrow($result) ) 
{ 
if ($leger == '') 
{ 
$leger = $row['item_name']; 
} 
} 
} 
// - 沒光的防具店、水怪的頭盔店、風神的鞋子店
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

	$rpgstatus = '<table width="142" cellpadding="0" cellspacing="0" border="0" class="bodyline">' .
			'<tr><td width="35%"><span class="gensmall">職 照:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_medals'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">等 級:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_level'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">H P:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_cur_hp'] . ' / ' . $postrow[$i]['rpg_max_hp'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">M P:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_cur_mp'] . ' / ' . $postrow[$i]['rpg_max_mp'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">經驗值:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_cur_exp'] . ' / ' . $postrow[$i]['rpg_max_exp'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">攻擊力:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_attack'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">防禦力:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_defense'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">魔 力:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_magic'] . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">速 度:</span></td><td><span class="gensmall">' . $postrow[$i]['rpg_speed'] . '</span></td></tr>' .
			'<tr><td><span class="gensmall">左 手:</span></td><td><span class="gensmall">' . $lefthand . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">右 手:</span></td><td><span class="gensmall">' . $righthand . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">頭 盔:</span></td><td><span class="gensmall">' . $safety . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">盔 甲:</span></td><td><span class="gensmall">' . $defend . '</span></td></tr>' . 
			'<tr><td><span class="gensmall">腳 部:</span></td><td><span class="gensmall">' . $leger . '</span></td></tr></table>';
ps.
如果論壇文章很多的話, 那麼資料庫作業會很吃重.

發表於 : 2006-04-25 19:33
Zeans
謝謝心靈捕手大大

現在這些資料都能夠正常的顯示了!!

發表於 : 2006-04-26 05:19
jwxinst
如果允許我在這裡插嘴的話, 那我必需要把老師的話再補上一句
●免費空間連結: http://www.pandela.com/

這個免空只有2mb的資料庫容量

如果你目前是用他來做測試論壇, 看看自己的能力而已那當然沒問題
但是如果你想用他當比較久一點的小論壇, 請小心點喔

ps: 流量他們都可以說是騙人
到了很高的時候, 他們自然會把他砍掉.....

這是我想補充的一點
ps; 電腦壞, 只能上來看xdddd

發表於 : 2006-04-26 13:07
Zeans
謝謝您的提醒!!

這個論壇我只是要拿來當作班網的事情

以及放一些要討論的報告用

發表於 : 2006-04-27 06:47
jwxinst
不用, 因為以前是免空組XDDDD最爽是把免空罵過堂

嗯, 那就好^^
記得備份喔