如何将PHP代码添加到URL
我应该使用什么php代码,以及如何将其添加到下面的下一篇文章url链接中,这将导致多维数组中的下一篇文章随后被回显 我打算依次复述一篇又一篇文章 谢谢大家! (form.php)如何将PHP代码添加到URL,php,Php,我应该使用什么php代码,以及如何将其添加到下面的下一篇文章url链接中,这将导致多维数组中的下一篇文章随后被回显 我打算依次复述一篇又一篇文章 谢谢大家! (form.php) 组: 第一组 第2组 第章: 第条: (process.php) 将链接到本章的下一篇文章。但是,您必须检查您是否在给定章节的最后一篇文章中,我将留给您我已将您的代码更正为echo$article++not echo($article+1),并且它已起作用。但我后来还添加了上一篇文章的url链接,除了$ART
组:
第一组
第2组
第章:
第条:
(process.php)
将链接到本章的下一篇文章。但是,您必须检查您是否在给定章节的最后一篇文章中,我将留给您我已将您的代码更正为echo$article++not echo($article+1),并且它已起作用。但我后来还添加了上一篇文章的url链接,除了$ARTICLE之外,其他代码都是相同的,但无法工作。我应该怎么做才能使这两个链接都有效?
<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
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>
<a href="process.php?group=<?php echo $group; ?>&chapter=<?php echo $chapter; ?>&article=<?php echo ($article + 1); ?>" style="text-decoration: none;">NEXT ARTICLE</a>