Jump to content

Recommended Posts

Help please - it's doing my head in!

 

i'm probably missing something here but have searched for an answer to no avail.

 

i'm using folder names on the server as links in a menu - to display thumbnail pics in chosen folder.

 

works fine as long as the folder name is in this format - 'abc_def_ghi_jkl' but not in this format 'abc def ghi jkl'.

 

the array $darr[] holds the folder name and will show it ok as a link but in the code shown $dirchoice only contains the folder name as far as the first space - ie. abc

 

Any ideas please?

<li><a href=<?php echo("$PHP_SELF?dirchoice=" . $darr[$x]) ?> ><?php echo($darr[$x]);?></a></li>

 

Link to comment
https://forums.phpfreaks.com/topic/40417-string-problem/
Share on other sites

You need to put quotes around the URL in the "href"

<li><a href="<?php echo $_SERVER['PHP_SELF'] . '?dirchoice=' . $darr[$x]) . '"><' . $darr[$x];?></a></li>

 

Actually, I would just echo the entire HTML string from within PHP:

<?php
echo '<a href="' . $_SERVER['PHP_SELF'] . '?dirchoice=' . $darr[$x]) . '"><' . $darr[$x] . '</a></li>';
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/40417-string-problem/#findComment-195572
Share on other sites

Thanks for the reply - tried both versions but for some reason they screwed up my menu formatting in a big way.

 

Anyway, a bit rushed so i went for the easy route and used str-replace to replace the underscores from the folder names with spaces - it looks better in the menu list.

 

when 've more time i'll have another look at this and see why it messed up the css formatting.

 

Thanks again -

 

Regards from Doug. aka Micky1955

 

 

Link to comment
https://forums.phpfreaks.com/topic/40417-string-problem/#findComment-195600
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.