snkx Posted July 15, 2006 Report Share Posted July 15, 2006 kā lai panāk to lai manā lapā būtu jaunākie topiki no foruma? Link to comment Share on other sites More sharing options...
v3rb0 Posted July 15, 2006 Report Share Posted July 15, 2006 pasties db kur šie glabājas un select from posti limit 10 Link to comment Share on other sites More sharing options...
snkx Posted July 15, 2006 Author Report Share Posted July 15, 2006 varētu vienkāršam cilvēkam saprotamā valodā? Link to comment Share on other sites More sharing options...
v3rb0 Posted July 15, 2006 Report Share Posted July 15, 2006 varētu. meklē gatavu scriptu kkur, jo izskatās ka pats neuzrakstīsi. Link to comment Share on other sites More sharing options...
SkyD Posted July 15, 2006 Report Share Posted July 15, 2006 mysql_query("SELECT nosaukums FROM posti ORDER BY id DESC, LIMIT 10"); Link to comment Share on other sites More sharing options...
snkx Posted July 15, 2006 Author Report Share Posted July 15, 2006 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 More sharing options...
v3rb0 Posted July 15, 2006 Report Share Posted July 15, 2006 html māki? Link to comment Share on other sites More sharing options...
snkx Posted July 15, 2006 Author Report Share Posted July 15, 2006 (edited) cepums tev, paldies liels bija tikai jāieliek <li> Edited July 15, 2006 by snkx Link to comment Share on other sites More sharing options...
snkx Posted July 15, 2006 Author Report Share Posted July 15, 2006 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 More sharing options...
SkyD Posted July 16, 2006 Report Share Posted July 16, 2006 (edited) Ja tev vajag jaunākos topikus, tad velc tos ārā. mysql_query("SELECT topika_nosaukums FROM topiki ORDER BY id DESC, LIMIT 10"); Edited July 16, 2006 by SkyD Link to comment Share on other sites More sharing options...
snkx Posted July 16, 2006 Author Report Share Posted July 16, 2006 $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 More sharing options...
snkx Posted July 16, 2006 Author Report Share Posted July 16, 2006 var kāds palīdzēt? Link to comment Share on other sites More sharing options...
snkx Posted July 19, 2006 Author Report Share Posted July 19, 2006 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 More sharing options...
v3rb0 Posted July 19, 2006 Report Share Posted July 19, 2006 (edited) 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 July 19, 2006 by v3rb0 Link to comment Share on other sites More sharing options...
snkx Posted July 19, 2006 Author Report Share Posted July 19, 2006 (edited) vai tas būtu ļoti grūti izdarāms, ja es palūgtu uzrakstīt priekšā? Edited July 19, 2006 by snkx Link to comment Share on other sites More sharing options...
Recommended Posts