So I have the following code:
echo '<li><a href="'.$Website.$Elements[2].'/'.$Row["povezava"].'" class="leftMenuArticlesInactive"></a><li>';
- $Website contains: http://www.somesite.com/test/
- $Elements[2] contains: sometext
- $Row["povezava"] contains: sometext2
All variables have nothing but letters in them.
Now my problem.
If I try to echo the following I get:
// I'm missing "sometext":
http://www.somesite.com/test/sometext2
// Should be like this:
http://www.somesite.com/test/sometext/sometext2
If I do print_r($Elements) I can see that $Elements[2] is "sometext".
Why can’t I echo $Elements[2] along with a few other variables?
edit: added more code
$Website = 'http://' . $_SERVER["SERVER_NAME"] . '/' . $Elements[1] . '/';
function ShowMenuOfParent($Parent, $Spacing) {
$Query = mysql_query("SELECT * FROM `izdelki_meni` WHERE `stars` = '$Parent';");
if(mysql_num_rows($Query) != 0) {
while($Row = mysql_fetch_array($Query)) {
$s = '<li><a href="'.$Website.$Elements[2].'/'.$Row["povezava"].'" class="leftMenuArticlesInactive">';
for($i = 0; $i < $Spacing;$i++) {
$s .= ' ';
}
$s .= $Row["ime"].'</a></li>';
echo $s;
ShowMenuOfParent($Row["id"], $Spacing + 8);
}
}
}
$Query = mysql_query("SELECT * FROM `izdelki_meni` WHERE `stars` = 0;");
if(mysql_num_rows($Query) != 0) {
echo '<ul>';
while($Row = mysql_fetch_array($Query)) {
echo '<li><a href="'.$Website.$Row["povezava"].'" class="leftMenuArticlesActive">'.$Row["ime"].'</a></li>';
if($Elements[2] == $Row["povezava"]) {
ShowMenuOfParent($Row["id"], 8);
}
}
echo '</ul>';
}
Actually,
echocan do that, so only this part of your question remains unresolved:What you can and what you can not often depends on what you’ve learned so far to do. As learning is subjective, it’s hard to answer that question by somebody else than you. But probably you can add more information what especially hinders you to understand your actual problem so others can better assist you.
The information you provide with your question is factually wrong. I can understand you have a problem and you would like to fix it, but what you actually do is that you make your problem bigger than it is by posting it here as an invitation for others to even do more guessing. I mean 10 persons are able to guess more than one person. So the way you ask is actually counter-productive and not helpful. Both for yourself as anybody else.
Instead of guessing you need to start to actually proof things step by step. Start with your own expectation:
And the code you’ve posted that is related to the output is:
You write that
$Websiteends with/test/, and additionally there is a slash in the output string (.'/'.), however the output itself does not even contain that extra string according to you:And that is already regardless what
$Elementsor$Rowcontains. Start thinking first, you need to analyze why that happens, and others can not help your with that, because we don’t have your software and your data to debug it. With some time you will learn your own best ways to find the mistakes you do.Take the time to setup yourself the xdebug debugger and step through your code then. It helps you to locate errors very quickly. And not only this time but also in the future.