This is a discussion on A question about laying out a page with php and html within the Php and MySQL forums, part of the Programming / Scripting / Coding category; Hi, I would like to be able to have the ability to lay out my php pages in anyway I ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| | #1 (permalink) |
| Newbie | Hi, I would like to be able to have the ability to lay out my php pages in anyway I like, but with just one page. I have a selection of articles in my MySQL database, and I have a php page called articles.php. Now, each article is placed on the same page, but which one depends on what the id is, e.g. aritlces.php?id=3 would bring in the article that is in row 3, and place it in the page in the layout that I've made on the html page. I would like to know if it is possible to take this way of working, and write the code in such a way that, depending on the amount of text or size of picture, or whatever, it will lay it out differently each time, but still on aritlces.php. This would be very helpful if I can do this, as it won't limit me to having the same layout for each article, but the layout will be different if there are two pictures, more words, a bigger/smaller picture etc. And is it possible to alter the table also using the php, basically so I can keep one page, but have each article layed out differently. Any help would be great, thanks. |
| | |
| | #3 (permalink) |
| Super Moderator | As Craig has suggested, save a few base CSS layouts and when you save the article in the database, also save the layout style and then use your PHP code to select which of the layout stylesheets you include. I'd suggest having a single sheet for the base layout and the article stylesheets with identical classes but in seperate files, this way the common page styles will be cached by the browser and you only have to pull back a small amount of styling data when you select a new layout.
__________________ Alex Monaghan - Monaghan Consultants Ltd Web hosting, ADSL, IT & Database consultancy Custom Web hosting on UK or USA servers using Linux (cPanel) or Windows (DotNetPanel) Mobile Phone Ringtones, Logos, Java Games & more |
| | |
| | #4 (permalink) |
| Newbie | Right, so I would use CSS to do this. I'm still learning all this stuff so I'll need to get some help. How exactly does it work, how does the php take the CSS and use it. Let's say I've written a CSS style exactly how I want it, what are the next steps I would take, like putting it in the database, having the article use that style etc. Thanks again. |
| | |
| | #5 (permalink) |
| Super Moderator | Sounds like you've taken on a big project to learn on when you don't know the fundamentals of HTML & CSS If I was you, I'd invest in some of the Sitepoint (www.sitepoint.com) CSS books and take a look through their tutorial sections while you're over there. As I suggested, simply store the stylesheet name in the database and when you create the HTML page in your PHP code, pop this into the header as an additional stylesheet link.
__________________ Alex Monaghan - Monaghan Consultants Ltd Web hosting, ADSL, IT & Database consultancy Custom Web hosting on UK or USA servers using Linux (cPanel) or Windows (DotNetPanel) Mobile Phone Ringtones, Logos, Java Games & more |
| | |
| Tags |
| html, laying, page, php, question |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Question about links | BillyB | Website Design Forum | 3 | 06-12-2006 13:42 |
| I have a question, plz look. | Arthur32 | General Webmaster Discussion | 0 | 18-08-2006 16:41 |
| Question regarding sedo. | robertall | General Webmaster Discussion | 2 | 28-07-2005 18:44 |
| Vb question | kastor | Search Engine Optimisation (SEO) | 1 | 24-05-2005 14:49 |
| www or not www that is the question | woodflooristcom | Search Engine Optimisation (SEO) | 1 | 16-02-2005 18:34 |