mysql query results in a particular css box?

I am working on redesigning my web site to use css boxes, several fixed boxes and one absolute positioned, it is the only box on the page that scrolls, whence it contains the body text. The other boxes contain the header/menu/ads/etc. Is it possible to have the menu items pull from mysql database and load the results in the one bodytext box? That way I don’t have to recreate the entire page for each menu item. Right?

Thanks.

It’s hard to understand exactly what you are looking for. Have you tried anything?

I’m guessing you just want 1 navigation that works on all pages, just use an include file:

[PHP]

Your Site
<?php include "/_template/top_nav.php";?>
[/PHP]

I found the solution: iframes.

I have used includes for years, but doing that means making a separate .php file for every page that is to be included. So if my menu has Home/Previous Blogs/Music/Contact/Etc/Etc/Etc then each of those pages is made of the same template file as the home page, and then include the relevant body text. That is what I want to get away from - all the separate yet similar pages.

With iframes I am now able to have just one home page, and use the iframe to load the contents of each subpage from a mysql db. It has simplified the overall maintenance considerably.

Now my site uses css boxes for the static parts - header/menu bar/ads/recent updates/etc and has one iframe which loads all the relevant data from the db. It’s quite cool. iframes have been around for some years now, I just never bothered to learn them until today.

Iframes? Are you serious? I’m sorry ifnit comes across as rude, I just have to make sure.

Either way, no iframes is not the solution

  1. use your server side code to directly output data where you want it

Or

  1. use client side code (javascript) to fetch data from the server side and display it in the appropriate place

yes, iframes, not frames, you do know the difference, right? iframes are a part of HTML5.

Here’s what I like about using an iframe - I have a primary menu, horizontal across the bottom of the header, the links open in the one body text frame, they don’t load an entire new page.
I also have a list of recent updates in a column on the right of the body area, and those links also open in the body text frame. There is a contact form, it used to be a separate page, now the form parts only are loaded into the body text frame, not the entire old contact page.

Yes I sadly used both frames and iframes on my first websites 15 years ago. Guessing this is trolling. Moving on

Trolling? Now I’m insulted. I come here with a legit question, looking for help, and this is what I get in response? I hope not everyone on this forum is like you. You want to see the website? It’s not fully completed but I will send you the link if you are interested in seeing it.

Chipw, do not be offended. iFrames and Frames have not been used in a long time due to the fact that they are very easy to hack. They are NOT secure and are seldom used by professionals.

JimL, just because someone does not understand what you are saying is no reason to call them a Troll !

Now, adding menus dynamically are handled as was stated by either using PHP, ASP or other server side code to build the needed code and send it out to the browsers. Or, you can create a browser-side code to query the server to load pages as needed. In my opinion, it is best to use PHP on server-side and send the pre-built pages as needed. You can use PHP’s Session variables to remember what page you are on.

Either way, perhaps you should give us further info on what you are trying to do. Also, this is a help site, we usually need to see some code to help you get it to work. Help us help you. Good luck…

After re-reading your early post, it appears you are using one DIV that contains your content for the page.

To load SQL or MySQL data just run a query to locate your data and enter it into that div. Since queries are done server-side, they handled before the data gets to your browser. So, you would have a simple query to grab the info, format it as needed and just print it out where needed.

You handle your question and place the formatted data into a PHP variable. Let’s call it $content.
Then, wherever this data needs to be used between your DIV tags, you print the data, something like:

<?PHP echo $content; ?>

Not sure if that is what you are asking about. Hope it helps…

Hi Ernie, yes, I know about all that and have used it for years. But that is on one query on one page, say the home page, then there has to be a contact page with it’s own query which can be called by an include into the div, then yet another full page with another query for the next page and so on, many pages all with their own query and included on the home page. That is what I am trying to get away from. With the iframe, which is only not secure if one is loading pages from outside your own server or website, I am able to run the query on the home page and each menu item loads in the frame, there are no need for individual include files. At least so it appears in my experimenting. Please correct me if I am wrong.

besides, if I frames are sooooooo bad as it seems a few, not the majority, say, then why is it still being developed into html5?

Well, since this is not a dicussion on iFrames, I will just say that not all browsers support them.
Also, you are correct that cross-domain links are the worst problem with iFrames. But, HTML5 is
not a trustworthy place for their use unless you place them into the HTML5’s “sandbox”. So, that
just adds more complexity to a needless item.

Now, your original post stated you were using CSS boxes with one being scrollable and the others fixed, I will assume you are talking about div’s. There are many many ways to load menu items, dynamic content into any DIV. If you have a list of menu items in a DB table, just pull them out as needed and translate that into the correct HTML and show it.

I guess I am confused on what you want to do and why you would want to use an “iFrame” for this.
If you can load info into an iFrame, you can load the same info just into a DIV in a similar manner.

But, since you are happy with your iframe version, should I mark this as solved?

My site is simple and can be done with a lot of static html pages, but that’s no fun. Over the years I have tried a few things just to learn and experiment. That is how we all learn what we know, right?

On my site I have only a few pages - music (where I have some songs I have written and recorded), previous blogs, a photo album (coppermine), a link to another site of mine for new english learners and a contact form.

On the home page there are a couple google ads, a list of recent blogs, a photo/linkedIn & facebook links and flag counter visitor counter.

The body text of the blogs is stored in a mysql db along with the date and title of the blogs. The blogs go back 8 years. I have a page called previous_blogs which contains the mysql query that creates a list of all the previous blogs.

My goal is simply to experiment a bit, learn something new, at least new to me. I have been doing basic web design since the late 90’s. Time to update what I know.

So when you say I can use mysql to load from a menu link into a particular div, can you point me to some info online?

Well, there are many ways to load content into a DIV. The simplest, of course, is to refresh the page with new options, or call itself, and let your load process handled filling in whatever info you want. Another way is to use AJAX to pull info and “refresh” a DIV with new data.

I have been experimenting with the “Bootstrap” library. Bootstrap has many features that are awesome to view and they flow dynamically. If you want something new, you might like to peek at that.
Here is a link to it: http://getbootstrap.com/

But, to use it, sometimes you need to get a template for it. There are thousands. Here are some:
http://bootstrapthemes.quora.com/25-Awseome-Twitter-Bootstrap-Themes-For-Better-Bootstrap-Designs

Down that page about 3/4, there is one called Awesome. It has a lot of nice samples for setting up pages. Just the displays, of course, you have to program the content and database access. But, it is only $8.
Here is a live demo of it so you can see what it can do:
http://www.portnine.com/Themes/AwesomeAdmin/pricing.html

Now back to our talk. I use SESSION variables to hide the current page I am on. At the top of the page, I use PHP to load this and set up the page depending on this (these) variables. If the user selects a link or button (I like buttons over links, but…) to alter the view, it posts to itself and uses that form to reset the current page options which are read BEFORE the page loads. During the loading of the page, it changes menus, layouts, text and graphics to fit the options selected. One site I am working on shows two entire different sites depending on the user’s access levels. Works like a charm. This is my preferred way.

The other, loading items dynamically is a bit trickier, but, has a nice “flow” to it so it is attractive. This would use AJAX to load a PHP page with variables in a get or post manner and “fill” in a DIV with the new “stuff”. This can be done in many many ways. The downside is that the AJAX code is partially shown in the browser if someone looks at the page code. Of course, using SESSION variables, most items are hidden from noisy surfers. To explain how to do this, here is a site that does it nicely. Click on one of the cars in the middle and you should see “stuff” appear. Since this is actually loading a PHP page into a page, it just appears and can have full PHP code in it to access databases, streamline menus using SESSION variables, whatever you wish.
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

Hope that gives you something to think about for a bit…

Yes its possible. I did the same thing years ago using js and Php.

Richei,

Long time no write… Glad to see you are still on the site!

ChipW was looking for something new to add to his site, so I was showing him some new stuff
he may not have seen lately… Any other ideas for him?

CYA in the Bitstream… Ernie

Idk, he might report me for trolling. Iframes were there long before html5 was ever thought of.

When the page loads, use jquery to send a post on Ajax call to a Php page that do all formatting, the just use the callback function to load the content into whatever div he wants it in.

Ok, thanks guys. Looks like Ajax is something worth learning. I will bookmark the links you provided and take a look.

I appreciate your input. At this time I think this thread can be closed.

No problem. I closed the thread. Good luck with your studying…

Sponsor our Newsletter | Privacy Policy | Terms of Service