This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Hilighting The Current Navigation Tab Using URL in PHP
hilighiting the current tab without php extension not working
<?php if ("index.php" || "index"==$Current)
{echo "selected";}else {echo "";}?>
I think you want:
<?php if ("index.php"==$Current || "index"==$Current) {
echo "selected";
}else {
echo "";
}
?>
What you wrote didn't really make sense.
This code
if ("index.php" || "index"==$Current)
already return true because
if ("index.php")
same
if ("index.php" != "")
Related
This question already has answers here:
How to use store and use session variables across pages?
(8 answers)
Reference - What does this error mean in PHP?
(38 answers)
Closed 2 years ago.
$_SESSION['Active'] = 1; I have defined this in my login.php file.
if($_SESSION['Active'] ==1){ I am checking if this exists in my AdminControl File
echo "Hello"; when I login this works.
}
if (isset($_POST['submit'])) { this is the code that I used for going back to the AdminControl Page
header("Location: AdminControl.php");
exit();
}
When I go back to the Admin Control the Hello disappears.
In this picture you can see that there is not Hello
on your admin control page you could add the following.
<?php if(isset($_SESSION['Active']) && ($_SESSION['Active'] == '1')) { echo "Hello"; } else { echo "Something else";} ?>
Hope this helps you.
This question already has answers here:
The 3 different equals
(5 answers)
Closed 5 years ago.
I am trying to figure out this issue I am having.
I am trying to create a link but ONLY if there's an admin logged in, otherwise the link should be hidden.
if ($administrator = true) {
echo '<a href="medewerkertoevoegen.php?id='.'">Medewerkers
toevoegen</a>';
}
else
{
echo '<span></span>';
}
I am not sure if this is how it should work, currently my database looks like this. http://i.imgur.com/CdgLXkj.png
Please let me know if you can help me because I am very new at this, thanks!
Because '=' is assignation (not comparing). You must use '==' or '==='.
if ($administrator === true) {
echo '<a href="medewerkertoevoegen.php?id='.'">Medewerkers
toevoegen</a>';
} else {
echo '<span></span>';
}
This question already has answers here:
The 3 different equals
(5 answers)
Closed 6 years ago.
if($_GET["content"] ="foo"){
echo("<h4>foo</h4>");
exit;
}
When I type in URL "127.0.0.1/_/index.php?content=foo" it seems to output the previous code I wrote
if($_GET["content"] ="picture"){
echo("Picture:<br>");
echo("<img src='./ku~1.jpg'></img>");
exit;
}
What is the problem here?
if($_GET["content"] ="picture"){
assigns $_GET["content"] the value "picture". You want to use
if($_GET["content"] =="picture"){
and
if($_GET["content"] =="foo"){
instead.
Have you started your file with
<?php
And you are assigning the value content by only using one =
Do this instead
if($_GET["content"] == "picture"){
echo "Picture:<br>";
echo '<img src="./ku~1.jpg"></img>';
exit;
}
You were also wrapping your echo with parentheses when they should be contained in quotations.
I forgot the first example... That should be:
if($_GET["content"] == "foo"){
echo "<h4>foo</h4>";
exit;
}
This question already has an answer here:
Enabling php.ini for backward compatibility
(1 answer)
Closed 9 years ago.
Ok so i want to have an include code on my index.php page that will include all of the other html pages within it. I used to do this using an id?=link.html link and this:
<?php
$id = $HTTP_GET_VARS['id'];
if ( !$id || $id == "" )
{
$number=10;
include("news/show_news.php");
}
else
{
include "$id";
}
?>
but apparantly http_get_vars is unrecognized or something? How can I fix this so that it will work? Or if things have changed, why should I not use this kind of thing for includes?
You can use $_GET to fetch the query string parameter by GET request, e.g.
index.php?id=123
The id value can be obtained by $_GET['id'].
p.s. your PHP codes are really old.
solved with the following:
<?php
if (!empty($_GET['id'])) {
$id = $_GET['id'];
$id = basename($id);
include("$id");
} else {
include("news/newsfilename.php");
}
?>
and
<a href="index.php?id=pagename.html">
Page Name
</a>
as the html
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to insert PHP into jQuery?
how to insert php on jquery/javascript ? for example
php
$tot =4;
javascript
$(function()
if( can put php here? )
eg : if( <?php tot > 4 ?> )
i want to put the php in 'if statement' ,it`s possible?
Try:
$(function() {
if(<?=$tot?> > 4) {
[...]
}
});
The <?=$tot?> part will effectively echo your $tot variable in the javascript code. Beware that if $tot evaluates to '' when converted to string, it could create a syntax error in javascript code.
You can use
if (<?php echo $tot; ?> > 4)