سيستم آرشيو

سلام... من يه سيستم بلاگ نوشتم الان تو قسمت سيستم آرشيوش موندم... اگه كسي مي دونه چه جوري مي شه نوشت كمك كنه... در ضمن آرشيو ماهيانه هم مي خوام باشه...
 
شرمنده

سورس برنامه رو نمي تونم بذارم ... فقط مي خوام بدونم چه جوريمي شه اينجوري آرشيو رو درست كرد ... منظور الگوريتمش هست... از چه دستوراتي بايد استفاده كنم... چه جوري مشخص كنم ماه ها رو جدا جدا نشون بده... مشكل من اينجاست :sad:
 

mosi20

Active Member
منظورت یه چیزی مثل تقویم هستش که روش کلیک کنند؟ مثل پرشینبلاگ؟
 
نه اونجوری نه... ببیت تو تیبل دیتابیسش یه ستون به نام time هست.. می دونم که باید این time رو یه جوری جدا کنم که متغییر های ماه و سال رو بدست بیارم بعدش اونو لیمیت کنم و یه Reuqest واسه تاریخ به صفحه اضافه کنم. مشکل من اینجاست که این تاریخه رو چه جوری از هم جدا کنم.... و چه جوری اونا رو بر اساس اون تاریخه مرتب کنم؟ آی دی من تو یاهو اینه : farshidmokh اگه تونستی کمک کن
 
خب با اینکه کسی جواب نداد ولی به هر حال یه جوری تونستم یه آرشیو جم و جور درست کنم براش ...یه مشکل جدید پیدا کردم.. الان می خوام ماه ها رو نشون بده مثلا بنویسه june 2005 این چه جوری امکان پذیره؟ البته ماه ها رو از اولین پستی که زدم حساب کنه و بعدش هر ماه رو بنویسه + لینکش که می شه archive.php?date=... اگه کسی می تونه کمک کنه
 

iman_ebru

Active Member
فرشید جان من اصلا متوجه نمیشنم که مشکل تو چی هست...

ایمان
 
ببینین الان من یه چیزی می خوام که بفهمه اولین پست من تو چه ماهی بوده بعدش از اون ماه به بعد یه دونه یه دونه ماه ها رو ایجاد کنه + لینکشون رو هم خودش بسازه .... یعنی ماه ها رو از اولین پست من به بعد پشت سر هم + لینکشون چاپ کنه.
 

miladmovie

Active Member
PHP:
	function NewsArchiveList()
	{
		$return_array=array();
		$end_date=jmaketime(23,59,59,jdate('m'),jdate('t'),jdate('Y'));
		$num=0;
		$query_begin_date="select  n_date from ".TABLE_PREFIX."news ORDER BY `n_date` ASC limit 0,1";
		$result_begin_date=db_query($query_begin_date);
		if($row_begin_date=db_fetch_array($result_begin_date))
		{
			
			$start_date=$row_begin_date[0];
			while ($start_date<=$end_date) {
				$star=jmaketime(0,0,0,jdate('m',$start_date),1,jdate('Y',$start_date));
				$end=jmaketime(23,59,59,jdate('m',$start_date),jdate('t',$start_date),jdate('Y',$start_date));
				$result_check_post=db_query("select count( * )  from ".TABLE_PREFIX."news where  n_date>'$star' and n_date<'$end' ");
				$row_check_post=db_fetch_array($result_check_post);
				if($row_check_post[0]!=0)
				{
					$return_array[$num]['Date']= jdate('F Y',$start_date);
					$return_array[$num]['Year']= jdate('Y',$start_date);
					$return_array[$num]['Month']= jdate('m',$start_date);
					$num++;
				}
				$start_date=jmaketime(0,0,0,(jdate('m',$start_date)+1),jdate('d',$start_date),jdate('Y',$start_date));
			}
			
		}
		return $return_array;
	}


این رو مطالعه کن هر جاش مشکلی بود بگو بهت بگم
این هم table اش هست :
کد:
CREATE TABLE `tbl_news` (
  `n_id` int(11) NOT NULL auto_increment,
  `n_title` longtext NOT NULL,
  `n_description` longtext NOT NULL,
  `n_date` varchar(250) NOT NULL default '',
  `n_pic` varchar(250) NOT NULL default '',
  `l_id` int(11) NOT NULL default '0',
  KEY `n_id` (`n_id`)
) TYPE=MyISAM ;

در مورد توابع jdate و jmaketime هم اگر مشکلی داشتی اینجا رو بخون :
http://farsiprojects.com/projects/JDF
 
دستت درد نکنه من خودم از تابع شما تو برنامه ام استفاده کردم ... خودم هم عضو فارسی پروجکت هستم تو قسمت phpbb که یادش بخیر... جوونی ها بودیم.به هر حال بالاخره یکی جواب درست و حسابی داد.
 
آقا ميلاد واسه من يه مشكلي پيش اومده: كدي كه من بعد تغيير و سازگار ساختن با سيستم دادم بهش اينه:
PHP:
function NewsArchiveList() 
    { 
        $return_array=array(); 
        $end_date=jmaketime(23,59,59,jdate('m'),jdate('t') ,jdate('Y')); 
        $num=0; 
        $query_begin_date="select  year from blog_entries ORDER BY `year` ASC limit 0,1"; 
        $result_begin_date=dbcaller($query_begin_date); 
        if($row_begin_date=mysql_fetch_array($result_begin_date)) 
        { 
             
            $start_date=$row_begin_date[0]; 
            while ($start_date<=$end_date) { 
                $star=jmaketime(0,0,0,jdate('m',$start_date),1,jdate('Y',$start_date)); 
                $end=jmaketime(23,59,59,jdate('m',$start_date),jdate('t',$start_date),jdate('Y',$start_date)); 
                $result_check_post=dbcaller("select count( * )  from blog_entries where  year>'$star' and year<'$end' "); 
                $row_check_post=mysql_fetch_array($result_check_post); 
                if($row_check_post[0]!=0) 
                { 
                    $return_array[$num]['Date']= jdate('F Y',$start_date); 
                    $return_array[$num]['Year']= jdate('Y',$start_date); 
                    $return_array[$num]['Month']= jdate('m',$start_date); 
                    $num++; 
                } 
                $start_date=jmaketime(0,0,0,(jdate('m',$start_date)+1),jdate('d',$start_date),jdate('Y',$start_date)); 
            } 
             
        } 
        return $return_array; 
    }
بعدش اين ارور رو مي ده:
کد:
Warning: mktime(): Windows does not support negative values for this function in D:\xampp\htdocs\pars\include\jalali.php on line 219
اگه مي شه كمك كنين كه مشكل كجاست
 
شرمنده هی پشت سر هم پست می دم... ببخشید... ولی یه چیزی الان که فرمت تاریخ رو تو دیتابیس تغییر دادم یعنی کردم mdY الان برنامه هیچ اروری نمی ده ولی فقط می نویسه:Array مشکل این کجاست؟
 

carp3

Member
فک کنم واسه اینه که تابع میلاد به زبان span نوشته شده من هم همین مشکل رو داشتم باید تبدیل به utf-8 شه تا مشکلش حل شه
 

miladmovie

Active Member
من هدفم این بود که روش رو یاد بگیری این کد هم که دادم یک قسمت از سایتی بود که نوشته بودم !
واسه تو که ننوشتم ! یکم باش کار کن ببین چه طوری کار می کنه بعدش خودت پیاده سازیش کن !
(مشکل از من بود که واسه کدهام کامنت نمی زارم ! )
اصلا کلا ساختار که من تاریخ رو ذخیره می کنم با کد تو فرق داره (البته من جدیدا با این روش ذخیره تاریخ مشکل پیدا کردم )
 
ایول عزیز زودتر می گفتی من مخمو با این کار نگیرم که چرا کار نمی کنه... ایول... باز خوب شد که گفتی
 
بازم معذرت مي خوام...من يه كد پيدا كردم ولي مشكل داره مي شه يه نفر چك كنه ببينه مشكلش چيه... من كه نفهميدم...:
PHP:
include ("dbconnect.php"); //retrieves the file that holds your database user info and password

//Now we need to set up the Next and Previous links which we can use to navigate through the archive. First lets define the variables we will use for them.

if($newsarchive) $newsarchive = 0; //If the variable $newsarchive is not defined, define it as 0

$archivenext = ($newsarchive + 10); //Define the variable $archivenext as the variable $newsarchive with 10 added to it
$archiveprevious = ($newsarchive - 10); //Define the variable $archiveprevious as the variable $newsarchive with 10 subtracted from it

//Time to run the query

$result = mysql_query("SELECT * FROM tablename ORDER BY id DESC LIMIT $newsarchive,10"); //Grab everything out of the table holding all of your data, but limit it to the first 10 entries starting at whatever your $newsarchive is currently equal to
//this means that if your $newsarchive = 10, this will display the news id's 10 to 20
//or if $newsarchive = 60, it will display the news id's 60-70

$totalresult = mysql_query("SELECT id FROM tablename"); //retrieve every row from your table
$num = mysql_num_rows($totalresult); //Number all of the rows in your database

//Now lets set up the actual visible previous and next links. We only want to set this up once. We dont want different links for every individual page. 
//We will use the variables defined above ro make these links automatically change for each seperate page

if ($archiveprevious >=0) //if the variable $archiveprevious (which is equal to $newsarchive - 10) is greater than or equal to 0...
{//do this function...
echo "Previous Page";//display a link to the same page your at, except take 10 away from the $newsarchive variable
echo "
"; //break after the link
} //end this function
else {//however, if $archiveprevious is not greater than or equal to zero, we do not want to display a link. 
//if we had a link to $PHP_SELF?newsarchive=-10, we would be displaying variables -10 through 0
//obviously, this is incorrect, so we use this else function to correct this
echo " ";
}

if ($archivenext < $num) //if $archive next is less than the total number of data, we want to display a link for people to go to the next page
{ //start function
echo "Next Page";//Display the link going to the next page, or next 10 pieces of data
echo "
";//break after the link
} //end this function
else {//however, if $archivenext is = or greater than total number of pieces of data, we do not want a link
echo " ";
}//end function

//Now that we have our Next and Previous links, we should display the actual data

while($row = mysql_fetch_assoc($result))//while there are rows in the table
{//do this
echo "$row[title]
$row[date]
$row[article]

"; //This will change for your archive results.
//change everything in the echo tag to display the data you want to display.
//This takes knowledge of using variables, so if your not sure what to do, go read more about php in our other tutorials
}//end this function


//OPTIONAL
//IF YOU WANT THE NEXT AND PREVIOUS LINKS DISPLAYED AGAIN AT THE BOTTOM OF YOUR PAGE
//JUST REMOVE THE /* AND */ BELOW. THIS IS THE EXACT CODE AS ABOVE!

/*

if ($archiveprevious >=0) //if the variable $archiveprevious (which is equal to $newsarchive - 10) is greater than or equal to 0...
{//do this function...
echo "Previous Page";//display a link to the same page your at, except take 10 away from the $newsarchive variable
echo "
"; //break after the link
} //end this function
else {//however, if $archiveprevious is not greater than or equal to zero, we do not want to display a link. 
//if we had a link to $PHP_SELF?newsarchive=-10, we would be displaying variables -10 through 0
//obviously, this is incorrect, so we use this else function to correct this
echo " ";
}

if ($archivenext < $num) //if $archive next is less than the total number of data, we want to display a link for people to go to the next page
{ //start function
echo "Next Page";//Display the link going to the next page, or next 10 pieces of data
echo "
";//break after the link
} //end this function
else {//however, if $archivenext is = or greater than total number of pieces of data, we do not want a link
echo " ";
}//end function

*/

?>
 

جدیدترین ارسال ها

بالا