How to make your website more flexible

The biggest pain is to discover that you need to change something in your site that covers 20 pages. When I created the Graveyard Database I kept running into the problem that i wanted to change something in the graveyard page. I would have to go to each page and make the changes. So I slowly learned to make a website very flexible from the start. Here is ways I found to make a site very flexible.

Use a CSS style page

This is probably the most obvious one, and common one. CSS stands for Cascading Style Sheets. It is a page on your website that each of your sites pages link to. It will determine the look of your site.  If you want to change the font in your whole site then you would just have to change one thing in your CSS page. If you just to change a div box, once again you just change one thing in your CSS page. Here is an example of a rule in a CSS page:

#graveInfo{
font-size:large;
height:auto;
margin-top: 150px;
right:auto;
left:auto;
font-family: Book Antiqua, Century Gothic;
width: 700px;}

Then my html tag would look like this <div id=”graveInfo”> code </div>.

Anything in the div tag will follow that rule.

Segment your website

Many times I ran into that I wanted to add an extra navigation menu item, but would have to change every page in the website. So if you know like the bottom or top of your site will stay consistent then it is best to create a separate page for each. So lets say you want to create a navigation menu and logo at the stop will stay the same through out your site. You would create a header page. Here is an example of one I did: header.php.

These are not full html pages, but just stop in the tracks where you want to stop. They do not close the html tag. You would just attach the header to your page and continue the page. Here is an example attaching an header in php:

<?php require(header.php) ?>

html code

</html>

This does not have to be just for headers and footers but also with functions or smaller sections in your site.

Use a database

This one may not be as important, but can be very helpful. For example, in my graveyard site I use the information about a particular graveyard many times through out the site. One day may come that I need to change the name of the graveyard but I do not want to have to change each pages individual. So if I played it smart I would create a graveyard database that I would poll when I need the information. So if I need to change the info I will just the database. Here is an example of how polling a MySQL data base may look (does not include connecting to MySQL database:

mysql_select_db(“greenbiz_grave”) or die(mysql_error());
$result = mysql_query(“SELECT * FROM sites WHERE id= $graveNum “)
or die(mysql_error());
$row = mysql_fetch_array( $result );
echo “<div id = \”title\”> Name: </div>”.$row['Name'].
“<br /> <div id = \”title\”>Location: </div>”.$row['City'].”, “.$row['State'];

mysql_select_db(“greenbiz_grave”) or die(mysql_error());

$result = mysql_query(“SELECT * FROM sites WHERE id= $graveNum “)      or die(mysql_error());

$row = mysql_fetch_array( $result );

echo “<div id = \”title\”> Name: </div>”.$row['Name']. “<br /> <div id = \”title\”>Location: </div>”.$row['City'].”, “.$row['State'];

This turns out looking like this: example (the top part).

Using functions

This is useful only when your using code like php or javascript. Lets say you write some code to grab the number of member you have on one page. Instead of just having the code set on that one page, you need to write the code in a function and call it. This function can be stored in your function.php file, which would be attached to your page. Here is an example I did:

function getMembers(){
echo “Number of members online: “;
echo mysql_num_rows($result);
echo ”  “;
echo ”  “;
echo $row['username'];
echo ”  “;
while($row = mysql_fetch_array($result)){
echo $row['username'];
echo ”  “;
}

This code would be in my function.php page. For me to call this php function I would have to attach the function.php file to my page by adding this: <?php require(function.php); ?>  toward the top. For me to call the php fuction, I would type: <?php getMembers(); ?>


Graveyard Database Logo

Has everything you want to know about grave yards. Plus has many celebrites and world leaders graves. Pssst it is my other site

Google + Profile
Check out Android Photo Mapping, its a app/site I been working on

  • wholesale nfl jerseys
  • wholesale nfl jerseys china
  • wholesale sports jerseys