PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : متخصصین php و سرور لطفا نظر بدهند



parsehost
June 24th, 2011, 21:50
سلام به همه دوستان کد زیر جهت نمایش اخرین ارسال های وی بی در وردپرس یا هر چیز دیگه ای هست :




<?php

// Copyright By WebAlfa
// http://www.webalfa.ir

echo '<div id="MTForumBlock">
<table id="webalfa-lastpost">
<tr class="MTForumfirst">
<td class="MTForumtitle">عنوان</td>

<td class="MTForumanswer">پاسخ</td>

<td class="MTForumview">بازديد</td>

<td class="MTForumlast">آخرين ارسال</td>
</tr>';

## CUSTOMIZE SETTINGS FOR YOUR SITE ##
$db_host = "local host"; // Change this if your MySQL database host is different.
$db_name = " "; // Change this to the name of your database.
$db_user = " "; // Change this to your database username.
$db_pw = " "; // Change this to your database password.

$forum_url = "http://forum.naghsh-negar.ir/"; // Change this to reflect to your forum's URL.
$forum_id = "";
$limit = "15"; // Number of posts displayed.
$txtlimit = "180"; // This is the character limit.

#######################################

// Connecting to your database
mysql_connect($db_host, $db_user, $db_pw)
OR die ("Cannot connect to your database");
mysql_select_db($db_name) OR die("Cannot connect to your database");

if ($forum_id) {
$forumid = "AND forumid=$forum_id";
}

if ($limit) {
$limited = "LIMIT $limit";
}
$thread_sql = mysql_query("SELECT threadid,title,lastpost,lastposter,replycount,view s FROM thread WHERE visible=1 AND open=1 $forumid ORDER BY lastpost DESC $limited");



while($thread_get=mysql_fetch_array($thread_sql))
{
$replycount = $thread_get['replycount'];
$views = $thread_get['views'];
$lastpost = $thread_get['lastpost'];
$poster = $thread_get['lastposter'];
$tid = $thread_get['threadid'];
$psql = mysql_query("SELECT postid FROM post WHERE threadid=$tid ORDER BY postid DESC");
$getp=mysql_fetch_array($psql);
$pid = $getp['postid'];
$title = $thread_get['title'];
$title = substr($title,0,$txtlimit);

echo "
<tr>
<td class=\"MTForumrowtitle\">
<a href=\"".$forum_url."showthread.php?t=$tid&p=$pid\">
$title</a></td>
<td class=\"MTForumanswer\">$replycount</td>
<td class=\"MTForumview\">$views</td>
<td class=\"MTForumlast\">$poster</td>
</tr>";


}

echo " </tr>
</table>
</div>";


?>


خب از اینجا به بعد مهم میشه وقتی مثلا انجمن و سایت در یک هاست یا سرور باشند لوکال هاست اوکی میشه و اخرین ارسال ها نمایش داده میشه اما مشکل از جایی پیش میاد که انجمن و سایت در یک سرور نباشند من به جای لوکال آی پی سرور انجمنو دادم اما متاسفانه ارتباط یر قرار نمیشه کسی از دوستان میتونه کمکم کنه ؟

HugeServer
June 24th, 2011, 22:03
سلام به همه دوستان کد زیر جهت نمایش اخرین ارسال های وی بی در وردپرس یا هر چیز دیگه ای هست :




<?php

// Copyright By WebAlfa
// http://www.webalfa.ir

echo '<div id="MTForumBlock">
<table id="webalfa-lastpost">
<tr class="MTForumfirst">
<td class="MTForumtitle">عنوان</td>

<td class="MTForumanswer">پاسخ</td>

<td class="MTForumview">بازديد</td>

<td class="MTForumlast">آخرين ارسال</td>
</tr>';

## CUSTOMIZE SETTINGS FOR YOUR SITE ##
$db_host = "local host"; // Change this if your MySQL database host is different.
$db_name = " "; // Change this to the name of your database.
$db_user = " "; // Change this to your database username.
$db_pw = " "; // Change this to your database password.

$forum_url = "http://forum.naghsh-negar.ir/"; // Change this to reflect to your forum's URL.
$forum_id = "";
$limit = "15"; // Number of posts displayed.
$txtlimit = "180"; // This is the character limit.

#######################################

// Connecting to your database
mysql_connect($db_host, $db_user, $db_pw)
OR die ("Cannot connect to your database");
mysql_select_db($db_name) OR die("Cannot connect to your database");

if ($forum_id) {
$forumid = "AND forumid=$forum_id";
}

if ($limit) {
$limited = "LIMIT $limit";
}
$thread_sql = mysql_query("SELECT threadid,title,lastpost,lastposter,replycount,view s FROM thread WHERE visible=1 AND open=1 $forumid ORDER BY lastpost DESC $limited");



while($thread_get=mysql_fetch_array($thread_sql))
{
$replycount = $thread_get['replycount'];
$views = $thread_get['views'];
$lastpost = $thread_get['lastpost'];
$poster = $thread_get['lastposter'];
$tid = $thread_get['threadid'];
$psql = mysql_query("SELECT postid FROM post WHERE threadid=$tid ORDER BY postid DESC");
$getp=mysql_fetch_array($psql);
$pid = $getp['postid'];
$title = $thread_get['title'];
$title = substr($title,0,$txtlimit);

echo "
<tr>
<td class=\"MTForumrowtitle\">
<a href=\"".$forum_url."showthread.php?t=$tid&p=$pid\">
$title</a></td>
<td class=\"MTForumanswer\">$replycount</td>
<td class=\"MTForumview\">$views</td>
<td class=\"MTForumlast\">$poster</td>
</tr>";


}

echo " </tr>
</table>
</div>";


?>


خب از اینجا به بعد مهم میشه وقتی مثلا انجمن و سایت در یک هاست یا سرور باشند لوکال هاست اوکی میشه و اخرین ارسال ها نمایش داده میشه اما مشکل از جایی پیش میاد که انجمن و سایت در یک سرور نباشند من به جای لوکال آی پی سرور انجمنو دادم اما متاسفانه ارتباط یر قرار نمیشه کسی از دوستان میتونه کمکم کنه ؟

Remote MYSQL Access !

parsehost
June 24th, 2011, 23:06
Remote MYSQL Access !
امکانش هست کمی مبتدیانه تر توضیح بدین ؟

websoft
June 24th, 2011, 23:06
$db_host = "yoursite.com:3306";

parsehost
June 24th, 2011, 23:07
ممنون از همه دوستان و مخصوصا websoft (http://www.webhostingtalk.ir/member/32/)