Jump to content
php.lv forumi

phpbb posti pirmajā lapā


snkx

Recommended Posts

tā, kaut ko es dabūju gatavu, bet posti nav viens zem otra - izklaidus, šeit to var redzēt zem uzraksta forums

 

function show_posts($limit = 10)

{

global $wpdb;

//Put your phpBB and wordpress database info here:

$WPDB = "web194_db1"; //WP db name

$PHPBBDB = "web194_db1"; //phpBB db name

$USERS_TABLE = "phpbb_users"; //phpbb user table

$TOPICS_TABLE = "phpbb_topics"; //phpbb topics table

$POSTS_TABLE = "phpbb_posts"; //phpbb posts table

$SITEURL = "http://atelpa.no.lv/forums"; //Forum URL with trailing /

//Do not edit beyond this point

 

$wpdb->select($PHPBBDB);

 

$results = $wpdb->get_results("SELECT * FROM $POSTS_TABLE ORDER BY post_time DESC LIMIT $limit");

 

if ($results)

{

foreach ($results as $post)

{

 

$topic = $wpdb->get_row("SELECT * FROM $TOPICS_TABLE WHERE topic_id = $post->topic_id");

 

if($topic)

{

echo "<a href='" . $SITEURL . "/viewtopic.php?t=$post->topic_id'>";

echo "</strong>$topic->topic_title";

echo "</a>";

echo "</li>";

}

}

}

 

$wpdb->select($WPDB);

}

 

?>

Link to comment
Share on other sites

tomēr ir problēma, viss kopā izskatās šadi

function show_posts($limit = 10)

{

global $wpdb;

//Put your phpBB and wordpress database info here:

$WPDB = "web194_db1"; //WP db name

$PHPBBDB = "web194_db1"; //phpBB db name

$USERS_TABLE = "phpbb_users"; //phpbb user table

$TOPICS_TABLE = "phpbb_topics"; //phpbb topics table

$POSTS_TABLE = "phpbb_posts"; //phpbb posts table

$SITEURL = "http://atelpa.no.lv/forums"; //Forum URL with trailing /

//Do not edit beyond this point

 

$wpdb->select($PHPBBDB);

 

$results = $wpdb->get_results("SELECT * FROM $POSTS_TABLE ORDER BY post_time DESC LIMIT $limit");

 

if ($results)

{

foreach ($results as $post)

{

 

$topic = $wpdb->get_row("SELECT * FROM $TOPICS_TABLE WHERE topic_id = $post->topic_id");

 

if($topic)

{

echo "<li> <a href='" . $SITEURL . "/viewtopic.php?t=$post->topic_id'>";

echo "</strong>$topic->topic_title" ;

echo "</a>";

echo "</li>";

}

}

}

 

$wpdb->select($WPDB);

}

 

?>

bet pirmajā lapā topiki rādas dīvaini, piemēram, ja pēdējie divi posti ir vienā tēmā, tad tēma parādas divreiz, varat lūdzu izpalīdzēt?

Link to comment
Share on other sites

$results = $wpdb->get_results("SELECT * FROM $POSTS_TABLE ORDER BY post_time DESC LIMIT $limit")
tagad ir šitāds, kas tur jāmaina? kas jāraksta pie nosaukums (*)?

 

ā ir arī šitāds

 

$topic = $wpdb->get_row("SELECT * FROM $TOPICS_TABLE WHERE topic_id = $post->topic_id")

Link to comment
Share on other sites

es biju domājis ka viss ir kārtībā, bet tiek izvilkti jaunizveidotie topiki, lai gan man vajag topikus kur ir jaunākie posti. kā to panākt?

 

function show_posts($limit = 10)

{

global $wpdb;

//Put your phpBB and wordpress database info here:

$WPDB = "web194_db1"; //WP db name

$PHPBBDB = "web194_db1"; //phpBB db name

$USERS_TABLE = "phpbb_users"; //phpbb user table

$TOPICS_TABLE = "phpbb_topics"; //phpbb topics table

$POSTS_TABLE = "phpbb_posts"; //phpbb posts table

$SITEURL = "http://atelpa.no.lv/forums"; //Forum URL with trailing /

//Do not edit beyond this point

 

$wpdb->select($PHPBBDB);

 

$results = $wpdb->get_results("SELECT * FROM $TOPICS_TABLE ORDER BY topic_time DESC LIMIT $limit");

 

if ($results)

{

foreach ($results as $post)

{

 

$topic = $wpdb->get_row("SELECT * FROM $TOPICS_TABLE WHERE topic_id = $post->topic_id");

 

if($topic)

{

echo "<li> <a href='" . $SITEURL . "/viewtopic.php?t=$post->topic_id'>";

echo "</strong>$topic->topic_title" ;

echo "</a>";

echo "</li>";

}

}

}

 

$wpdb->select($WPDB);

}

 

?>

Link to comment
Share on other sites

kam tos divus selectus tur vajag?

kverijs aptuveni šitāds

select * from postu_tabula inner join topicu_tabula on topicu_tabula.posta_id=posta_tabula.id group by topicu_tabula.id order by postu_tabula.laiks desc LIMIT 10

Edited by v3rb0
Link to comment
Share on other sites

×
×
  • Create New...