0
下nest.php頁面包含一個多維數組$法律,它包含羣體的法律與章包含在其中幾個文章的。回聲在下一篇文章或一篇文章中使用URL
我所做的以前的文章和下一篇文章動態URL鏈接回顯另一個順序後一篇文章。
但是我應該在這些(2)url上添加什麼樣的PHP代碼,以便在特定章節的最後一篇文章被回顯時跳到下一章?
<?php
session_start();
$laws=array(
"group1"=>array(
"1"=>array(
"1"=>"This is article (1) in chapter (1) of (group1)",
"2"=>"This is article (2) in chapter (1) of (group1)",
"3"=>"This is article (3) in chapter (1) of (group1)",
),
"2"=>array(
"1"=>"This is article (1) in chapter (2) of (group1)",
"2"=>"This is article (2) in chapter (2) of (group1)",
"3"=>"This is article (3) in chapter (2) of (group1)",
),
),
"group2"=>array(
"1"=>array(
"1"=>"This is article (1) in chapter (1) of (group2)",
"2"=>"This is article (2) in chapter (1) of (group2)",
"3"=>"This is article (3) in chapter (1) of (group2)",
),
"2"=>array(
"1"=>"This is article (1) in chapter (2) of (group2)",
"2"=>"This is article (2) in chapter (2) of (group2)",
"3"=>"This is article (3) in chapter (2) of (group2)",
),
)
);
if(isset($_GET['group']) && isset($_GET['chapter']) && isset($_GET['article'])){
$grp = $_GET['group'];
$chap = $_GET['chapter'];
$art = $_GET['article'];
}else{
$grp = 'group1';
$chap = '1';
$art = '1';
}
if(isset($laws[$grp][$chap][$art])){
$_SESSION['group'] = $grp;
$_SESSION['chapter'] = $chap;
$_SESSION['article'] = $art;
}
$group = $_SESSION['group'];
$chapter = $_SESSION['chapter'];
$article = $_SESSION['article'];
$previousarticle = $_SESSION['article'];
echo $laws[$group][$chapter][$article]; // ALL ARTICLES TO BE ECHOED HERE!!!!!
echo '<br/>';
?>
<!-------------- PREVIOUS Article and NEXT Article URLS ------------------->
<a href="nest.php?group=<?php echo $group; ?>&chapter=<?php echo $chapter; ?>&article=<?php echo --$previousarticle ; ?>" style="text-decoration: none;">PREVIOUS ARTICLE</a>
<br/>
<a href="nest.php?group=<?php echo $group; ?>&chapter=<?php echo $chapter; ?>&article=<?php echo ++$article ; ?>" style="text-decoration: none;">NEXT ARTICLE</a>
這可能是答案,但你需要遮光更多的光線。這個多維數組有**組=>章節=>文章。** – user2075752 2013-04-09 07:43:13