どの php コードを使用する必要があり、それを以下のNEXT ARTICLE url リンクにどのように追加すれば、多次元配列の次の記事が後でエコーバックされるようになりますか?
記事を次々と反響させていきたいと思います。
ありがとうございました!
(フォーム.php)
<form action="process.php" method="get">
Group:
<select name="group">
<option value="group1">Group1</option>
<option value="group2">Group2</option>
</select>
Chapter:
<input type="text" name="chapter">
Article:
<input type="text" name="article">
<input type="submit" value="Go to Article">
</form>
(プロセス.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)",
),
)
);
$grp= $_GET['group'];
$chap = $_GET['chapter'];
$art = $_GET['article'];
if(isset($laws[$grp]) && isset($laws[$grp][$chap]) && isset($laws[$grp][$chap][$art])){
$_SESSION['group'] = $grp;
$_SESSION['chapter'] = $chap;
$_SESSION['article'] = $art;
}else{
$_SESSION['group'] = 'group1';
$_SESSION['chapter'] = '1';
$_SESSION['article'] = '1';
}
$group = $_SESSION['group'];
$chapter = $_SESSION['chapter'];
$article = $_SESSION['article'];
echo $laws[$group][$chapter][$article]; // ALL NEXT ARTICLES TO BE ECHOED HERE!!!!!
?>
<a href="process.php" style="text-decoration: none;">NEXT ARTICLE</a>