How to make the link 'index.php?x' display x section on a page
I was trying to make a site with different parts which will be shown with a questionmark (like index.php?notes, index.php?options, etc.). Normally I see this often on search query pages or blogs (with an ?q="question").
On my index.php page i have set multiple sections that will be shown if the user presses a href link.
I know that this can be done with the anchor link in css (with #options), but since I am using php, I would like to try that.
This is my code at the moment:
<body>
<p>
[<a href="?notes">Notes</a>]
[<a href="?categories">Categories</a>]
[<a href="?options">Options</a>]
</p>
<?php
if($display == 'categories') {
echo "<h4>Categories</h4>";
} else if ($display == "notes") {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
?>
</body>
php html mysql
add a comment |
I was trying to make a site with different parts which will be shown with a questionmark (like index.php?notes, index.php?options, etc.). Normally I see this often on search query pages or blogs (with an ?q="question").
On my index.php page i have set multiple sections that will be shown if the user presses a href link.
I know that this can be done with the anchor link in css (with #options), but since I am using php, I would like to try that.
This is my code at the moment:
<body>
<p>
[<a href="?notes">Notes</a>]
[<a href="?categories">Categories</a>]
[<a href="?options">Options</a>]
</p>
<?php
if($display == 'categories') {
echo "<h4>Categories</h4>";
} else if ($display == "notes") {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
?>
</body>
php html mysql
What is$display
?
– kerbholz
Jan 2 at 13:03
add a comment |
I was trying to make a site with different parts which will be shown with a questionmark (like index.php?notes, index.php?options, etc.). Normally I see this often on search query pages or blogs (with an ?q="question").
On my index.php page i have set multiple sections that will be shown if the user presses a href link.
I know that this can be done with the anchor link in css (with #options), but since I am using php, I would like to try that.
This is my code at the moment:
<body>
<p>
[<a href="?notes">Notes</a>]
[<a href="?categories">Categories</a>]
[<a href="?options">Options</a>]
</p>
<?php
if($display == 'categories') {
echo "<h4>Categories</h4>";
} else if ($display == "notes") {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
?>
</body>
php html mysql
I was trying to make a site with different parts which will be shown with a questionmark (like index.php?notes, index.php?options, etc.). Normally I see this often on search query pages or blogs (with an ?q="question").
On my index.php page i have set multiple sections that will be shown if the user presses a href link.
I know that this can be done with the anchor link in css (with #options), but since I am using php, I would like to try that.
This is my code at the moment:
<body>
<p>
[<a href="?notes">Notes</a>]
[<a href="?categories">Categories</a>]
[<a href="?options">Options</a>]
</p>
<?php
if($display == 'categories') {
echo "<h4>Categories</h4>";
} else if ($display == "notes") {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
?>
</body>
php html mysql
php html mysql
edited Jan 2 at 13:03
Mr. Plopkoek
asked Jan 2 at 13:00
Mr. PlopkoekMr. Plopkoek
185
185
What is$display
?
– kerbholz
Jan 2 at 13:03
add a comment |
What is$display
?
– kerbholz
Jan 2 at 13:03
What is
$display
?– kerbholz
Jan 2 at 13:03
What is
$display
?– kerbholz
Jan 2 at 13:03
add a comment |
3 Answers
3
active
oldest
votes
When using ?q=question
you can access it in PHP via $_GET['q']
. In your case, since you don't have q
set, but ?notes
you need to access it via $_GET['notes']
. Try this:
<?php
if (isset($_GET['categories'])) {
echo "<h4>Categories</h4>";
} elseif (isset($_GET['notes'])) {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
1
Thank you, it works as expected!
– Mr. Plopkoek
Jan 2 at 13:17
add a comment |
You could set a GET variable p
and read that; e.g.
<a href="?p=notes">notes</a>
and in PHP $_GET['p']
add a comment |
if you don't want to use any keys, then you can use this code:
if(isset($_GET)){
$page = key($_GET);
}
But this solution is not very good it can mess your code later. I suggest to use with key i.e. ?p=notes
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006852%2fhow-to-make-the-link-index-phpx-display-x-section-on-a-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
When using ?q=question
you can access it in PHP via $_GET['q']
. In your case, since you don't have q
set, but ?notes
you need to access it via $_GET['notes']
. Try this:
<?php
if (isset($_GET['categories'])) {
echo "<h4>Categories</h4>";
} elseif (isset($_GET['notes'])) {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
1
Thank you, it works as expected!
– Mr. Plopkoek
Jan 2 at 13:17
add a comment |
When using ?q=question
you can access it in PHP via $_GET['q']
. In your case, since you don't have q
set, but ?notes
you need to access it via $_GET['notes']
. Try this:
<?php
if (isset($_GET['categories'])) {
echo "<h4>Categories</h4>";
} elseif (isset($_GET['notes'])) {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
1
Thank you, it works as expected!
– Mr. Plopkoek
Jan 2 at 13:17
add a comment |
When using ?q=question
you can access it in PHP via $_GET['q']
. In your case, since you don't have q
set, but ?notes
you need to access it via $_GET['notes']
. Try this:
<?php
if (isset($_GET['categories'])) {
echo "<h4>Categories</h4>";
} elseif (isset($_GET['notes'])) {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
When using ?q=question
you can access it in PHP via $_GET['q']
. In your case, since you don't have q
set, but ?notes
you need to access it via $_GET['notes']
. Try this:
<?php
if (isset($_GET['categories'])) {
echo "<h4>Categories</h4>";
} elseif (isset($_GET['notes'])) {
echo "<h4>Delete Notes</h4>";
} else {
echo "<h4>Options</h4>";
}
answered Jan 2 at 13:10
kerbholzkerbholz
2,16221119
2,16221119
1
Thank you, it works as expected!
– Mr. Plopkoek
Jan 2 at 13:17
add a comment |
1
Thank you, it works as expected!
– Mr. Plopkoek
Jan 2 at 13:17
1
1
Thank you, it works as expected!
– Mr. Plopkoek
Jan 2 at 13:17
Thank you, it works as expected!
– Mr. Plopkoek
Jan 2 at 13:17
add a comment |
You could set a GET variable p
and read that; e.g.
<a href="?p=notes">notes</a>
and in PHP $_GET['p']
add a comment |
You could set a GET variable p
and read that; e.g.
<a href="?p=notes">notes</a>
and in PHP $_GET['p']
add a comment |
You could set a GET variable p
and read that; e.g.
<a href="?p=notes">notes</a>
and in PHP $_GET['p']
You could set a GET variable p
and read that; e.g.
<a href="?p=notes">notes</a>
and in PHP $_GET['p']
answered Jan 2 at 13:07
Erik TerwanErik Terwan
1,8811326
1,8811326
add a comment |
add a comment |
if you don't want to use any keys, then you can use this code:
if(isset($_GET)){
$page = key($_GET);
}
But this solution is not very good it can mess your code later. I suggest to use with key i.e. ?p=notes
add a comment |
if you don't want to use any keys, then you can use this code:
if(isset($_GET)){
$page = key($_GET);
}
But this solution is not very good it can mess your code later. I suggest to use with key i.e. ?p=notes
add a comment |
if you don't want to use any keys, then you can use this code:
if(isset($_GET)){
$page = key($_GET);
}
But this solution is not very good it can mess your code later. I suggest to use with key i.e. ?p=notes
if you don't want to use any keys, then you can use this code:
if(isset($_GET)){
$page = key($_GET);
}
But this solution is not very good it can mess your code later. I suggest to use with key i.e. ?p=notes
answered Jan 2 at 13:11
JohnnyB1988JohnnyB1988
1467
1467
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54006852%2fhow-to-make-the-link-index-phpx-display-x-section-on-a-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What is
$display
?– kerbholz
Jan 2 at 13:03