-
June 24th, 2011, 21:50
#1
عضو جدید
متخصصین php و سرور لطفا نظر بدهند
سلام به همه دوستان کد زیر جهت نمایش اخرین ارسال های وی بی در وردپرس یا هر چیز دیگه ای هست :
کد:
<?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,views 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>";
?>
خب از اینجا به بعد مهم میشه وقتی مثلا انجمن و سایت در یک هاست یا سرور باشند لوکال هاست اوکی میشه و اخرین ارسال ها نمایش داده میشه اما مشکل از جایی پیش میاد که انجمن و سایت در یک سرور نباشند من به جای لوکال آی پی سرور انجمنو دادم اما متاسفانه ارتباط یر قرار نمیشه کسی از دوستان میتونه کمکم کنه ؟
-
-
June 24th, 2011 21:50
# ADS
-
June 24th, 2011, 22:03
#2
پاسخ : متخصصین php و سرور لطفا نظر بدهند

نوشته اصلی توسط
parsehost
سلام به همه دوستان کد زیر جهت نمایش اخرین ارسال های وی بی در وردپرس یا هر چیز دیگه ای هست :
کد:
<?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,views 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 !
-
تعداد تشکر ها ازHugeServer به دلیل پست مفید
-
June 24th, 2011, 23:06
#3
عضو جدید
پاسخ : متخصصین php و سرور لطفا نظر بدهند

نوشته اصلی توسط
HugeServer
Remote MYSQL Access !
امکانش هست کمی مبتدیانه تر توضیح بدین ؟
-
-
June 24th, 2011, 23:06
#4
پاسخ : متخصصین php و سرور لطفا نظر بدهند
کد PHP:
$db_host = "yoursite.com:3306";
-
تعداد تشکر ها از websoft به دلیل پست مفید
-
June 24th, 2011, 23:07
#5
عضو جدید
پاسخ : متخصصین php و سرور لطفا نظر بدهند
ممنون از همه دوستان و مخصوصا websoft
-