Donny Bahama
-
Posts
17 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Donny Bahama
-
-
If I want to link to a section/element within a page, and also pass GET parameters, which would be correct:
http://mysite.net/thispage.php#section1?ref=123
OR...
http://mysite.net/thispage.php?ref=123#section1
Or, if neither is correct, what's the right way?
-
Nevermind. I figured out the problem. Thanks for the help!
-
Thank you, Ingolme. Including those blocks made my test file work. But my actual files are more complicated. They're basically a full web page, divided up into chunks so I can require the header file and require the footer file so that, if I decide to make changes to the navmenu or the footer, I only have to change them in one place.
Everything worked beautifully until I decided I wanted to mix in some php. Under those circumstances, what is the right way to do this?
-
In the actual (not the test) files, there's a bunch of html code in part1, then I use the php open/close tags, run several commands which result in a bunch of text being assigned to a variable ($promotext) then, in part2, I try to write that string to the page (again, in the middle of a bunch of html code, so I use
<?php echo $promotext; ?>
but the text isn't shown on the final/main page.
-
28 minutes ago, iwato said:
if you use the require( ) function, there is no need to use the open( ) function. It is just like copying part2.php into part1.php at that point where you insert the require( ) function.
Thank you for your response, iwato. I was only using fopen/fwrite/fread as an alternative method to try to get the variable text from one part to another (because it's just NOT working for me.
I tried a simple test...
Complete contents of test1.php:
<?php require "part1.php"; require "part2.php"; require "part3.php"; ?>
Complete contents of part1.php:
$city = "Danville";
Complete contents of part2.php:
$citydesc = "pleasant";
Complete contents of part3.php:
echo "$city is a $citydesc place to live.";
When I go to test1.php in my browser, here is the full text of the page:
Quote$city = "Danville";$citydesc = "pleasant";echo "$city is a $citydesc place to live.";
-
Let's say I have main.php which consists of:
<?php require "part1.php"; require "part2.php"; require "part3.php"; ?>
If I define/set a variable in part1.php (i.e. $city = "Danville"; ), shouldn't I be able to echo $city in part2.php ?
If not, why not? (And what would be the appropriate workaround? I've tried using fopen/fwrite/fread but for some reason, the file isn't being written. :frustrated:)
-
If you click on the "Services" item in my navigation menu, the nav bar gets really tall (instead of just a portion of it dropping down) and all the items in the nav menu get aligned to the bottom. It looks pretty crappy. Can anyone suggest the best/right way to correct it? Thanks for your time and consideration!
-
I found the answer here: https://www.w3schools.com/howto/howto_html_include.asp
Only it doesn't work.
-
It occurs to me that it might be a good idea to have the pages on my site be modular... Is there some way I can just include (like I would in php) a file for my banner, navigation, footer, etc. I'm currently going through and editing every file on my site - all because I decided to make a change to my nav menu. If I have to go with php pages instead, I can do that, but I thought I'd check first.
If there is a way to do this, is it well-supported by all browsers (even old ones/IE/etc.)? If I have to go with php pages, are there SEO issues/complications to doing so? I would assume they would only look at the rendered pages, right?
-
18 minutes ago, dsonesuk said:
Wow! That works great! (I wish I understood why it works. ".popup:before" would be a lot more logical than ".popup:after") Anyway, thank you! I think I can adapt that to work for me.
-
That doesn't seem to work. It places it within the div (where all the popups are - at the bottom of the main content) with a top margin that looks to be about 10% of the screen height. (I used 10vh.) I tried using position:absolute instead of fixed. Same result.
-
I'm using a script that toggles different popup divs when different links are clicked. The problem is the placement of the popup with regard to the screen height. I always want the popups centered horizontally so each popup has margin-left and margin-right set to auto -- but setting margin-top and margin-bottom to auto doesn't work. Is there some way to position the popups at the top of the visible screen so that even if it's viewed on a relatively small screen (i.e. a smartphone in portrait mode), the popup will still pop up in a place that's vertically appropriate, regardless of how far down the page the user has scrolled?
The fact that position:sticky exists makes me think that there must be some way of doing this but when I try to detect where the top of a sticky background image is, I always get 0px.
-
I just want to post a big THANK YOU! to W3Schools. It's my go-to reference for HTML, CSS and Javascript. The Try-It editor is awesome and SO useful. You guys ROCK!
-
Here's something interesting I tried that seems like a good start. I'll document it here in case it helps anyone else...
I broke the line of text into 4 (approx. equal length) chunks. within each chunk, I replaced the spaces with non-breaking space characters - , leaving actual spaces between each of the quarters. That seems to help a lot. Now I'll play with max-width and breakpoints to get it right where I want it.
-
I'll look into that. Thanks for the guidance!
-
Say I have a wide div (100%) which contains a single line of text. If the screen is less than a certain width, the line will wrap. Depending on the width of the screen, there could be one long line of text with a single word on the second line. That looks crappy. Is there some way I can tell it to split the line in the middle if it won't fit on one line? Or in thirds if it won't fit on 2 lines? Or in fourths, etc.....
Formatting URL with section link and GET parameters
in PHP
Posted
I did some trial and error. In case anyone else needs to know, the second example worked. The first example did not.