<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1034951" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1034951</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202888</link>
    <description> &lt;p&gt;ok thanks for the help am now going to mess around and see what i can do!!! Will up date this post if i manage to do something incredible.&lt;/p&gt;
&lt;p&gt;Thanks again, lots of help.&lt;/p&gt;
 </description>
     <pubDate>Sun, 25 Jun 2006 14:43:41 +0000</pubDate>
 <dc:creator>benf</dc:creator>
 <guid isPermaLink="false">comment 1202888 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202887</link>
    <description> &lt;p&gt;Yes to all the first bits.  &lt;/p&gt;
&lt;p&gt;With regards to setting the user, you could always put the subdomain in the user table of the database as well.  That way you could just check the subdomain and add that to your select statement.  So the previous select would end up as something along the lines of...&lt;/p&gt;
&lt;p&gt;&#039;SELECT * FROM style_definitions, user_info WHERE user_info.user_id = &#039;.$_SESSION[&quot;uer_id&quot;].&#039; AND user_info.user_subdomain = &#039;.$thisSubdomain.&#039; and user_info.user_id = style_definitions.user_id&#039;&lt;/p&gt;
&lt;p&gt;Somthing like that anyway.&lt;/p&gt;
 </description>
     <pubDate>Sun, 25 Jun 2006 14:39:52 +0000</pubDate>
 <dc:creator>Shirthead</dc:creator>
 <guid isPermaLink="false">comment 1202887 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202885</link>
    <description> &lt;p&gt;Yes that makes good sense, thanks for a reply with a hangover by the way. But, does it mean that each attribute from the database, like border, color etc have to be set in a session of their own and then declared in the stylesheet like&lt;/p&gt;
&lt;p&gt;html {&lt;br /&gt;
border: &lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt; $_SESSION&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;border&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]; &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;;&lt;br /&gt;
color: &lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt; $_SESSION&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;color&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]; &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;also how can i grab the username from the URL like &lt;a href=&quot;http://www.mysite.com/website_temp?user=user1&quot; class=&quot;bb-url&quot;&gt;mysite.com/website_temp?user=user1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;to load up the appropriate styles, would i use $_GET[id] and put it in a session as well?&lt;/p&gt;
&lt;p&gt;Think i am getting it.&lt;/p&gt;
&lt;p&gt;But if i managed to assign a sub domain to all users how can i grab the sub domain part as the id like &lt;a href=&quot;http://www.user1.mysite.com&quot; class=&quot;bb-url&quot;&gt;user1.mysite.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Also if i want to class each part of the template, i may need a table for the classes and values and one table for the usernames and other info.&lt;/p&gt;
&lt;p&gt;example;&lt;/p&gt;
&lt;p&gt;create table users {&lt;br /&gt;
username varchar(30)&lt;br /&gt;
password varchar(30)&lt;br /&gt;
email_address text&lt;br /&gt;
address&lt;br /&gt;
phone_number&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;create table styles {&lt;br /&gt;
class varchar(50)&lt;br /&gt;
border&lt;br /&gt;
color&lt;br /&gt;
background&lt;br /&gt;
font&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;get the idea, i need to somehow join the two to get the username and styles for each.&lt;/p&gt;
&lt;p&gt;unless each user has his own table on registration and perhaps the name is the name of the table is the same as the username the could just ask the database to load up the values of the table which has the name $_SESSION[user_id] or perhaps the $_GET[id]. ????&lt;/p&gt;
 </description>
     <pubDate>Sun, 25 Jun 2006 14:12:32 +0000</pubDate>
 <dc:creator>benf</dc:creator>
 <guid isPermaLink="false">comment 1202885 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202881</link>
    <description> &lt;p&gt;Bit hungover today, so apologies in advance if this is not as clear as it should be.&lt;/p&gt;
&lt;p&gt;GETTING THE INFO&lt;/p&gt;
&lt;p&gt;If you are storing the user_id in the style definition table then you wouldn&#039;t need to do a join.  Something along the lines of the following would get all you need (assuming that your user_id is already stored in a sesson):&lt;/p&gt;
&lt;p&gt;&#039;SELECT * FROM style_definitions WHERE user_id = &#039;.$_SESSION[&quot;uer_id&quot;]&lt;/p&gt;
&lt;p&gt;Once you have got that from the database just create a look to put each value in the session.&lt;/p&gt;
&lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;Quote: &quot;In addition to that I&#039;d probably grab the style information and save it to a cookie/session - only if that cookie/session is not already set (and therefor clearning it when they edit the style information). This would reduce the number of hits on the database.&quot;&lt;/p&gt;
&lt;p&gt;Not sure i quite understand what you are saying here?
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;OK - breaking that down a bit:&lt;/p&gt;
&lt;p&gt;1. Somewhere at the top of every page (before any output) I&#039;d have an include file that..&lt;br /&gt;
  a. checks whether the style session has already been saved as a session&lt;br /&gt;
  b. if it hasn&#039;t then it gets the information from the database and saves it all to the session&lt;br /&gt;
  c. if nothing is in the database (for instance, user has not changed the style) then set some default values&lt;br /&gt;
2. Have a page somewhere for users to edit the style that&lt;br /&gt;
   a. edits the relevant database records&lt;br /&gt;
   b. clears the session containing the style information (so that on the next page load this will all be collected from the database again).&lt;/p&gt;
&lt;p&gt;Does that make any more sense?&lt;/p&gt;
 </description>
     <pubDate>Sun, 25 Jun 2006 10:28:22 +0000</pubDate>
 <dc:creator>Shirthead</dc:creator>
 <guid isPermaLink="false">comment 1202881 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202854</link>
    <description> &lt;p&gt;Yes i get the idea, infact it just came to me tonight before reading your post. The username and class will be a joint PK (cant remember what it is called when you have two attributes as a PK) I like the idea of having the styles loaded into a session, that way it doesnt need to load up each time.&lt;br /&gt;
But i dont know how i can grab the information out of the database. I mean, would i have two tables, one for the user, which would include the username password and email address..etc and one for the styles which includes the username, class, attributes..etc. Would i have to use a join when i query the database?&lt;/p&gt;
&lt;p&gt;&quot;In addition to that I&#039;d probably grab the style information and save it to a cookie/session - only if that cookie/session is not already set (and therefor clearning it when they edit the style information). This would reduce the number of hits on the database.&quot;&lt;/p&gt;
&lt;p&gt;Not sure i quite understand what you are saying here?&lt;/p&gt;
&lt;p&gt;I am reasonably new to all this database stuff and this is the biggest task i have had to do, remember i need to somehow load up the content of all the pages, i figured there would be another table and in that would be a username, page_id(like about_us, contact..etc) and the actual content itself.&lt;/p&gt;
&lt;p&gt;Would it be possible to explain all this in simpler terms, perhaps in more depth?&lt;/p&gt;
&lt;p&gt;Thanks for the help.&lt;/p&gt;
 </description>
     <pubDate>Sat, 24 Jun 2006 21:35:47 +0000</pubDate>
 <dc:creator>benf</dc:creator>
 <guid isPermaLink="false">comment 1202854 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202838</link>
    <description> &lt;p&gt;OK - understand now.  didn&#039;t quite grasp it before.  It could still be done with writing to files, but the advantages are greatly diminished if each user has their of style, so I&#039;ll assume the database approach.&lt;/p&gt;
&lt;p&gt;I&#039;d probably still have an basic style-sheet with anything in it that applies to all users - for instance if you are using CSS for common layout.&lt;/p&gt;
&lt;p&gt;In addition to that I&#039;d probably grab the style information and save it to a cookie/session - only if that cookie/session is not already set (and therefor clearning it when they edit the style information).  This would reduce the number of hits on the database.&lt;/p&gt;
&lt;p&gt;For the style information itself, what you have is not far off.  Add a user_id to that table and you  will have the basic functionality.&lt;/p&gt;
&lt;p&gt;If you are offering options  - rather than allowing users to actually type in the values you might want another couple of tables: 1 to list the classes and 1 to list the options within each of those classes.&lt;/p&gt;
&lt;p&gt;Does that make any sense?&lt;/p&gt;
 </description>
     <pubDate>Sat, 24 Jun 2006 12:16:31 +0000</pubDate>
 <dc:creator>Shirthead</dc:creator>
 <guid isPermaLink="false">comment 1202838 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202837</link>
    <description> &lt;p&gt;yes each user can create a style. But they have their own url as well so this will be the key to which styles to load up.&lt;/p&gt;
&lt;p&gt;example.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.user1.mysite.com&quot; class=&quot;bb-url&quot;&gt;user1.mysite.com&lt;/a&gt; user1 will be the PK for the styles to load up&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.user2.mysite.com&quot; class=&quot;bb-url&quot;&gt;user2.mysite.com&lt;/a&gt; will have a different stylesheet to load up.  &lt;/p&gt;
&lt;p&gt;Somehow i need the users table to link in with the styles table.&lt;/p&gt;
 </description>
     <pubDate>Sat, 24 Jun 2006 11:42:48 +0000</pubDate>
 <dc:creator>benf</dc:creator>
 <guid isPermaLink="false">comment 1202837 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202836</link>
    <description> &lt;p&gt;Think I understand.  Is the idea that every user gets their own style set-up, or that any user can change the overall style?&lt;/p&gt;
 </description>
     <pubDate>Sat, 24 Jun 2006 11:22:42 +0000</pubDate>
 <dc:creator>Shirthead</dc:creator>
 <guid isPermaLink="false">comment 1202836 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202834</link>
    <description> &lt;p&gt;the idea is that anyone can edit it through straight forward forms, where some parts have  tag where they can only choose certain words...etc does it make sense.&lt;/p&gt;
 </description>
     <pubDate>Sat, 24 Jun 2006 11:16:48 +0000</pubDate>
 <dc:creator>benf</dc:creator>
 <guid isPermaLink="false">comment 1202834 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/web-database-development/database-driven-stylesheet#comment-1202833</link>
    <description> &lt;p&gt;sounds quite server intensive. compared with a cached style sheet.  Why not physically write over the file instead?&lt;/p&gt;
 </description>
     <pubDate>Sat, 24 Jun 2006 11:09:27 +0000</pubDate>
 <dc:creator>Shirthead</dc:creator>
 <guid isPermaLink="false">comment 1202833 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
