สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

ปรับแต่งแก้ไขโค้ด ปัญหาการติดตั้งและการใช้งาน Mod ต่างๆ เพิ่มเพิ่มความสามารถของ บอร์ด ไม่รู้จะใช้ Mod อะไร ดี ถามได้ที่นี่ ติดตั้ง Mod แล้วมีปัญหา มี Mod ดีๆ อย่าง share เพื่อนเชิญบอร์ดนี้

Moderator: phpbb, mindphp, ผู้ดูแลกระดาน

ตอบกลับโพส
tossapron007
phpBBThailand Newbie
phpBBThailand Newbie
โพสต์: 5
ลงทะเบียนเมื่อ: 03 มิ.ย. 2011, 18:50

สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย tossapron007 »

ผมใช้โค๊ดนี้ มันดึงมาหมดครับ ผมต้องการที่จะแยกดึงมาเป็นหมวดหมู่ครับ รบกวนเขียนโค๊ดให้ทีครับ

โค้ด: เลือกทั้งหมด

<?php
$connection = mysql_connect(localhost,"XXXXX"," YYYYY") or die("Service temporairly unavailable");
/* **XXXXX* : user ที่ใช้เข้าฐานข้อมูล YYYYY :/* pass ที่ใช้เข้าฐานข้อมูล */
$db = mysql_select_db("AAAAA",$connection) or die("Service temporairly unavailable"); /* AAAAA:ชื่อฐานข้อมูล */

$sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,7"; 


$cs1="set character_set_results=utf8";
mysql_query($cs1)or die('error query:'.mysql_error());
$cs2="set character_set_client=utf8";
mysql_query($cs2)or die('error query:'.mysql_error());
$cs3="set character_set_connection=utf8";
mysql_query($cs3)or die('error query:'.mysql_error());


$result = mysql_query($sql) or die("Service temporairly unavailable");
for($x=1;$x<=7;$x++){
$row = mysql_fetch_array($result);

   echo "<img src=http://www.xn--42cl7aoi1brr5b5a1c6kci8o.com/pic/football.gif border=0 alt='Topic $tid'>\n"; /*พาร์ทของรูป*/
   
   echo "<a href = \"http://www.xn--42cl7aoi1brr5b5a1c6kci8o.com/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]\" target = \"_blank\">$row[topic_title]</a><br>"; /* BBBBB : โดเมนเว็บบอร์ดของคุณ*/
}
?>
ภาพประจำตัวสมาชิก
phpbb
phpBBThailand VIP Members
phpBBThailand VIP Members
โพสต์: 3189
ลงทะเบียนเมื่อ: 19 มิ.ย. 2008, 00:26
ติดต่อ:

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย phpbb »

โค้ด: เลือกทั้งหมด

$sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,7"; 
แก้เป็น

โค้ด: เลือกทั้งหมด

$sql = "select * from phpbb_topics WHERE forum_id= *** order by topic_last_post_time desc limit 0,7";  
*** คือ id ของหมวดที่ต้องการเอามาแสดง
โหลด phpBB3 ภาษาไทย ทั้งหน้าเว็บ และ admin
รวมพลคนใช้ phpBB3 แนะนำคนอื่นบ้างนะครับ ทุกคำถามจะได้มีคำตอบ แนะนำคนอื่นๆบ้างนะ ช่วยๆกันไป

สมาชิกใหม่ ก่อนถามแนะนำตัว
http://www.phpbbthailand.com/viewforum.php?f=41
กฏการใช้งานบอร์ด
http://www.phpbbthailand.com/viewtopic.php?f=37&t=5940
tossapron007
phpBBThailand Newbie
phpBBThailand Newbie
โพสต์: 5
ลงทะเบียนเมื่อ: 03 มิ.ย. 2011, 18:50

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย tossapron007 »

ขอบคุณมากครับ
littlegiant
phpBBThailand Full Member
phpBBThailand Full Member
โพสต์: 43
ลงทะเบียนเมื่อ: 01 มิ.ย. 2012, 15:40

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย littlegiant »

ไม่ทราบต้องใส่ code ที่ไฟล์ไหนเหรอครับ index หรือว่าไรอ่าคับ >_<
ภาพประจำตัวสมาชิก
phpbb
phpBBThailand VIP Members
phpBBThailand VIP Members
โพสต์: 3189
ลงทะเบียนเมื่อ: 19 มิ.ย. 2008, 00:26
ติดต่อ:

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย phpbb »

littlegiant เขียน:ไม่ทราบต้องใส่ code ที่ไฟล์ไหนเหรอครับ index หรือว่าไรอ่าคับ >_<
ต้องการใส่ที่ไหน ก็เอาไปวาง ที่นั่นได้เลย
แต่ต้องเป็น .php นะครับ
โหลด phpBB3 ภาษาไทย ทั้งหน้าเว็บ และ admin
รวมพลคนใช้ phpBB3 แนะนำคนอื่นบ้างนะครับ ทุกคำถามจะได้มีคำตอบ แนะนำคนอื่นๆบ้างนะ ช่วยๆกันไป

สมาชิกใหม่ ก่อนถามแนะนำตัว
http://www.phpbbthailand.com/viewforum.php?f=41
กฏการใช้งานบอร์ด
http://www.phpbbthailand.com/viewtopic.php?f=37&t=5940
littlegiant
phpBBThailand Full Member
phpBBThailand Full Member
โพสต์: 43
ลงทะเบียนเมื่อ: 01 มิ.ย. 2012, 15:40

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย littlegiant »

อ้อ ขอบคุณมากครับ
littlegiant
phpBBThailand Full Member
phpBBThailand Full Member
โพสต์: 43
ลงทะเบียนเมื่อ: 01 มิ.ย. 2012, 15:40

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย littlegiant »

รบกวนถามอีกนิดนึงนะครับ คือโค้ดหน้า index ผมมันเป็นอย่างนี้อ่ะครับ ใช้ wordpress อ่ะคับ ผมอยากให้กระทู้ล่าสุดของบอร์ดมาแสดงผลหน้าแรกง่ะครับ

<?php if (is_archive()) $post_number = get_option('chameleon_archivenum_posts');

if (is_search()) $post_number = get_option('chameleon_searchnum_posts');

if (is_tag()) $post_number = get_option('chameleon_tagnum_posts');

if (is_category()) $post_number = get_option('chameleon_catnum_posts'); ?>

<?php get_header(); ?>



<?php include(TEMPLATEPATH . '/includes/breadcrumbs.php'); ?>



<?php include(TEMPLATEPATH . '/includes/top_info.php'); ?>



<div id="content" class="clearfix">

<div id="left-area">

<?php

global $query_string;

$i = 0;

if (is_category()) query_posts($query_string . "&showposts=$post_number&paged=$paged&cat=$cat");

else query_posts($query_string . "&showposts=$post_number&paged=$paged");

?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php include(TEMPLATEPATH . '/includes/entry.php'); ?>

<?php endwhile; ?>

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }

else { ?>

<?php include(TEMPLATEPATH . '/includes/navigation.php'); ?>

<?php } ?>

<?php else : ?>

<?php include(TEMPLATEPATH . '/includes/no-results.php'); ?>

<?php endif; wp_reset_query(); ?>

</div> <!-- end #left-area -->



<?php get_sidebar(); ?>

</div> <!-- end #content -->



<?php get_footer(); ?>

ทีนี้ผมก็ลองใส่โค้ดที่ดูจากกระทู้ที่ให้มา ไว้ต่อท้าย แบบนี้น่ะครับ

<?php if (is_archive()) $post_number = get_option('chameleon_archivenum_posts');

if (is_search()) $post_number = get_option('chameleon_searchnum_posts');

if (is_tag()) $post_number = get_option('chameleon_tagnum_posts');

if (is_category()) $post_number = get_option('chameleon_catnum_posts'); ?>

<?php get_header(); ?>



<?php include(TEMPLATEPATH . '/includes/breadcrumbs.php'); ?>



<?php include(TEMPLATEPATH . '/includes/top_info.php'); ?>



<div id="content" class="clearfix">

<div id="left-area">

<?php

global $query_string;

$i = 0;

if (is_category()) query_posts($query_string . "&showposts=$post_number&paged=$paged&cat=$cat");

else query_posts($query_string . "&showposts=$post_number&paged=$paged");

?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php include(TEMPLATEPATH . '/includes/entry.php'); ?>

<?php endwhile; ?>

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }

else { ?>

<?php include(TEMPLATEPATH . '/includes/navigation.php'); ?>

<?php } ?>

<?php else : ?>

<?php include(TEMPLATEPATH . '/includes/no-results.php'); ?>

<?php endif; wp_reset_query(); ?>

</div> <!-- end #left-area -->



<?php get_sidebar(); ?>

</div> <!-- end #content -->



<?php get_footer(); ?>
<?php
$connection = mysql_connect(localhost,"XXXXX"," YYYYY") or die("Service temporairly unavailable");
/* **XXXXX* : user ที่ใช้เข้าฐานข้อมูล YYYYY :/* pass ที่ใช้เข้าฐานข้อมูล */
$db = mysql_select_db("AAAAA",$connection) or die("Service temporairly unavailable"); /* AAAAA:ชื่อฐานข้อมูล */

$sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,7";


$cs1="set character_set_results=utf8";
mysql_query($cs1)or die('error query:'.mysql_error());
$cs2="set character_set_client=utf8";
mysql_query($cs2)or die('error query:'.mysql_error());
$cs3="set character_set_connection=utf8";
mysql_query($cs3)or die('error query:'.mysql_error());


$result = mysql_query($sql) or die("Service temporairly unavailable");
for($x=1;$x<=7;$x++){
$row = mysql_fetch_array($result);

echo "<img src=http://www.xn--42cl7aoi1brr5b5a1c6kci8o ... otball.gif border=0 alt='Topic $tid'>\n"; /*พาร์ทของรูป*/

echo "<a href = \"http://www.xn--42cl7aoi1brr5b5a1c6kci8o ... w[topic_id]\" target = \"_blank\">$row[topic_title]</a><br>"; /* BBBBB : โดเมนเว็บบอร์ดของคุณ*/
}
?>

แล้วก็ไปเปลี่ยนชื่อ user ,db name,pass โดเมนบอร์ดน่ะครับ ผลปรากฏว่าเข้าหน้าแรกเวบไม่ได้เลย เลยต้องทำกลับเป็นอันเดิมน่ะครับ ถึงจะแสดงผลหน้าแรกได้ตามปรกติ
littlegiant
phpBBThailand Full Member
phpBBThailand Full Member
โพสต์: 43
ลงทะเบียนเมื่อ: 01 มิ.ย. 2012, 15:40

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย littlegiant »

รบกวนถามอีกนิดนึงนะครับ คือโค้ดหน้า index ผมมันเป็นอย่างนี้อ่ะครับ ใช้ wordpress อ่ะคับ ผมอยากให้กระทู้ล่าสุดของบอร์ดมาแสดงผลหน้าแรกง่ะครับ

<?php if (is_archive()) $post_number = get_option('chameleon_archivenum_posts');

if (is_search()) $post_number = get_option('chameleon_searchnum_posts');

if (is_tag()) $post_number = get_option('chameleon_tagnum_posts');

if (is_category()) $post_number = get_option('chameleon_catnum_posts'); ?>

<?php get_header(); ?>



<?php include(TEMPLATEPATH . '/includes/breadcrumbs.php'); ?>



<?php include(TEMPLATEPATH . '/includes/top_info.php'); ?>



<div id="content" class="clearfix">

<div id="left-area">

<?php

global $query_string;

$i = 0;

if (is_category()) query_posts($query_string . "&showposts=$post_number&paged=$paged&cat=$cat");

else query_posts($query_string . "&showposts=$post_number&paged=$paged");

?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php include(TEMPLATEPATH . '/includes/entry.php'); ?>

<?php endwhile; ?>

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }

else { ?>

<?php include(TEMPLATEPATH . '/includes/navigation.php'); ?>

<?php } ?>

<?php else : ?>

<?php include(TEMPLATEPATH . '/includes/no-results.php'); ?>

<?php endif; wp_reset_query(); ?>

</div> <!-- end #left-area -->



<?php get_sidebar(); ?>

</div> <!-- end #content -->



<?php get_footer(); ?>

ทีนี้ผมก็ลองใส่โค้ดที่ดูจากกระทู้ที่ให้มา ไว้ต่อท้าย แบบนี้น่ะครับ

<?php if (is_archive()) $post_number = get_option('chameleon_archivenum_posts');

if (is_search()) $post_number = get_option('chameleon_searchnum_posts');

if (is_tag()) $post_number = get_option('chameleon_tagnum_posts');

if (is_category()) $post_number = get_option('chameleon_catnum_posts'); ?>

<?php get_header(); ?>



<?php include(TEMPLATEPATH . '/includes/breadcrumbs.php'); ?>



<?php include(TEMPLATEPATH . '/includes/top_info.php'); ?>



<div id="content" class="clearfix">

<div id="left-area">

<?php

global $query_string;

$i = 0;

if (is_category()) query_posts($query_string . "&showposts=$post_number&paged=$paged&cat=$cat");

else query_posts($query_string . "&showposts=$post_number&paged=$paged");

?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php include(TEMPLATEPATH . '/includes/entry.php'); ?>

<?php endwhile; ?>

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }

else { ?>

<?php include(TEMPLATEPATH . '/includes/navigation.php'); ?>

<?php } ?>

<?php else : ?>

<?php include(TEMPLATEPATH . '/includes/no-results.php'); ?>

<?php endif; wp_reset_query(); ?>

</div> <!-- end #left-area -->



<?php get_sidebar(); ?>

</div> <!-- end #content -->



<?php get_footer(); ?>
<?php
$connection = mysql_connect(localhost,"XXXXX"," YYYYY") or die("Service temporairly unavailable");
/* **XXXXX* : user ที่ใช้เข้าฐานข้อมูล YYYYY :/* pass ที่ใช้เข้าฐานข้อมูล */
$db = mysql_select_db("AAAAA",$connection) or die("Service temporairly unavailable"); /* AAAAA:ชื่อฐานข้อมูล */

$sql = "select * from phpbb_topics order by topic_last_post_time desc limit 0,7";


$cs1="set character_set_results=utf8";
mysql_query($cs1)or die('error query:'.mysql_error());
$cs2="set character_set_client=utf8";
mysql_query($cs2)or die('error query:'.mysql_error());
$cs3="set character_set_connection=utf8";
mysql_query($cs3)or die('error query:'.mysql_error());


$result = mysql_query($sql) or die("Service temporairly unavailable");
for($x=1;$x<=7;$x++){
$row = mysql_fetch_array($result);

echo "<img src=http://www.xn--42cl7aoi1brr5b5a1c6kci8o ... otball.gif border=0 alt='Topic $tid'>\n"; /*พาร์ทของรูป*/

echo "<a href = \"http://www.xn--42cl7aoi1brr5b5a1c6kci8o ... w[topic_id]\" target = \"_blank\">$row[topic_title]</a><br>"; /* BBBBB : โดเมนเว็บบอร์ดของคุณ*/
}
?>

แล้วก็ไปเปลี่ยนชื่อ user ,db name,pass โดเมนบอร์ดน่ะครับ ผลปรากฏว่าเข้าหน้าแรกเวบไม่ได้เลย เลยต้องทำกลับเป็นอันเดิมน่ะครับ ถึงจะแสดงผลหน้าแรกได้ตามปรกติ
littlegiant
phpBBThailand Full Member
phpBBThailand Full Member
โพสต์: 43
ลงทะเบียนเมื่อ: 01 มิ.ย. 2012, 15:40

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย littlegiant »

ผมต้องแก้ไขอะไรยังไงบ้างอ่ะครับ ^^"
ภาพประจำตัวสมาชิก
phpbb
phpBBThailand VIP Members
phpBBThailand VIP Members
โพสต์: 3189
ลงทะเบียนเมื่อ: 19 มิ.ย. 2008, 00:26
ติดต่อ:

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย phpbb »

littlegiant เขียน:ผมต้องแก้ไขอะไรยังไงบ้างอ่ะครับ ^^"
หา plugin ของ wordpress มาใส่เลยก็ได้ครับ ไม่ต้องแก้เอง
ตัวอย่างนี้สำหรับ เว็บที่เขียนขึั้นมาเอง
โหลด phpBB3 ภาษาไทย ทั้งหน้าเว็บ และ admin
รวมพลคนใช้ phpBB3 แนะนำคนอื่นบ้างนะครับ ทุกคำถามจะได้มีคำตอบ แนะนำคนอื่นๆบ้างนะ ช่วยๆกันไป

สมาชิกใหม่ ก่อนถามแนะนำตัว
http://www.phpbbthailand.com/viewforum.php?f=41
กฏการใช้งานบอร์ด
http://www.phpbbthailand.com/viewtopic.php?f=37&t=5940
littlegiant
phpBBThailand Full Member
phpBBThailand Full Member
โพสต์: 43
ลงทะเบียนเมื่อ: 01 มิ.ย. 2012, 15:40

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย littlegiant »

รบกวนถามเพิ่มอีกเรื่องนึงได้มั๊ยครับ คือเวบของผมที่ว่าเป็น wordpress ผมจ้างเค้าทำน่ะครับ และผมโหลดปลั๊กอินมาตัวนึงตามคำแนะนำเรียบร้อยแล้วครับ(ตอนแรกไม่รู้ว่ามันมีปลั๊กอินสำหรับ เชื่อมต่อ phpbb ด้วย ^^") ชื่อ phpbb recent topics ทีนี้มัันให้ใส่ sql database ผมก็เลยเข้าไปดูที่โฮสที่ผมใช้บริการอยู่ปรากฏว่า db ที่ทำไว้มันมี 3 ตัว และทีมที่จ้างทำเวบไซท์ก็ทิ้งงานไปแล้ว ติดต่อไม่ได้ ทีนี้ผมลองใส่ทีละอันจนหมดแล้วมันขึ้นแบบนี้หมดเลยอ่ะครับ Database Error. Connectivity to phpBB failed T^T ทำไงดีครับ
littlegiant
phpBBThailand Full Member
phpBBThailand Full Member
โพสต์: 43
ลงทะเบียนเมื่อ: 01 มิ.ย. 2012, 15:40

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย littlegiant »

ผมเจอที่ที่ใช้ใส่โค้ดแล้วครับ ไม่ได้อยู่ที่ index.php แต่อยู่ที่ home.php สำหรับ wordpress ทีนี้ขอถามเพิ่มเติมอีกนิดนึงนะครับ ตรง [topipc_id][forum_id][topic_title] มันคืออะไรเหรอครับ ให้ปล่อยว่างไว้แบนี้หรือใส่เป็น url หรือใส่เป็นพิมพ์ชื่อหัวข้อตามปรกติได้เลย เช่น [topic_title] ใส่เป็น [พูดคุยทั่วไป] อะไรแบบนี้หรือเปล่าครับ งงอ่ะครับ แล้วพาร์ทของรูปนี่มันคืออะไรอ่ะครับ ขอโทษครับ มือใหม่จริงๆครับ 8O
littlegiant
phpBBThailand Full Member
phpBBThailand Full Member
โพสต์: 43
ลงทะเบียนเมื่อ: 01 มิ.ย. 2012, 15:40

Re: สอบถามเรื่องการดึงข้อมูลบอร์ดไปหน้าเว็บ

โพสต์ โดย littlegiant »

plug in ที่หามาใช้ทั้งหมดมันไม่สามารถนำมาแสดงผลหน้าแรกได้อ่ะครับ มันทำได้แค่ไปแสดงผลไว้ที่ page,post น่ะครับ ^^"
ตอบกลับโพส

ย้อนกลับไปยัง

ผู้ใช้งานขณะนี้

กำลังดูบอร์ดนี้: 93 และ บุคคลทั่วไป 0 ท่าน