Steps I have taken for my Final Project
Basically my Thought Process Here
N510 Final Project
1: I recieved information about the Final Project.
2: Found out that I had to pick out a Country from the List
3: I chose the country Chile.
4: The First thing I did was get my Database in MySQL Ready.
5: I First was coding all of it by hand in MySQL by using insert statements
6: Then I discovered fileReader.php
7: I took that and made a source code to run in MySQL. Command mysql> source result_table.sql;
8: Then I changed the name of the table to Result.
9: I ended up with 4 Tables. DistrictID, ElectionID, Party and Result
10: Then I established my Primary Keys. I used auto_increment on two of them. I wanted to make sure I had unique identifers.
11: I discovered that they all link to the Results Table. The Results Table has 3 Foreign Keys
12: Then I began work on laying out the Table Relationships. I made a Diagram in Photoshop. I was able to do a screen shot of each table to show in the diagram how each of the tables relate to one another.
13: The next step I figured was just getting something if anything to pop up from the database I just had created. Then I began researching and getting advice from a friend on getting a code developed to show the tables of my database on the website.
14: I established pages to show my database information.
15: I found out that you can link pages differently by using PHP Code at the top of the page. You use some sort of a Get Method in order to obtain the page you want the user to go to. Basically this code is redirecting to the proper page. Where as before I was using html and linked it to the direct url.
16: The first thing is you have to connect to the database. I used a directory called lib and then put the connectToDb.php inside.
17: Then you have to make sure you put that code inside your pages so it knows where to connect to MySQL
18: Then you have to select your data.
19: Order the columns by using Order by.
20: Then you have to use echo to place the table data on to the webpage.
21: Once I got something working or at least appearing on screen I began work on the HTML. Basically I wanted somethin to look Pretty. I began to plan out in my head how my final project website was going to look.
22: I then began research on-line for pictures of Chile and some interesting facts about this country.
23: I used Dreamweaver and my own HTML experiences to create the webpage. I just used basic tables and a little CSS to help build the page.
24: I then began to place those pictures and things into the website.
25: After a page was established I added links like to the table data and table relationships.
26: I then discovered that I needed to some how explain some Voting Percentages and Number of Political Parties to my users according to Oncourse. So I then began theories of how I might go about this.
27: I played around with some things that we had done in class. Going over in my head how it all worked. I also got a book called PHP 5 / MySQL For the Absolute Beginner by Andy Harris to help me see some of this PHP Code.
28: I then discovered that I might need to have a reference section and also give credit to the sources of my pictures.
29: I then thought out about a theory of what or how I was going to do this.
30: My first thought is that I needed to establish Foreign Keys so that when I form queries it would work properly. I had researched this and had came to the conclusion I could use ALTER TABLE Result
ADD FOREIGN KEY (DistrictID) REFERENCES DistrictID(DistrictID);
31: This did not work. It gave me an error message. ERROR 1005 (HY000): Can't create table './rijmorri_db/#sql-a3e_11471.frm' (errno: 150);
32: I have come to the conclusion that maybe we do not have access to place a foreign key.
33: My first initial thought was for the 3 pages about Voting Percentages and the Number of Political Parties I would just have one line sentences with variables addressing those questions.
34: I quickly realized that I think this is a little more complicated then I thought.
35: I then began working on thinking about queries. I had thought of the Voting Percentages in terms of Averages as we had a similar MySQL code we had worked on early on in the semester. This was What is the highest, lowest and average salary among the doctors? Basically here you would do a select statement which is select MAX(salary) as highest, MIN(salary) as lowest, AVG(salary) as average from salary;
36: Then I thought to myself no I think they have to be actual Votes and Percentages. The first is grouping Party, Election and District. The Second is by Party and Election.
37: Lets just do the Party and Election one. I began to come up with a Theory.
38: My Short Theory behind this was it should probably be set up the same way the other tables were set up and how we as a class set up some of the examples we did in class. First I want to establish a connection. Then I want to come up with some kind of query. I want to fetch my data. I want to Display that data using tables and the php key word here echo.
39: My Question is now what kind of query to develop here? I will need columns that are not in the original table. I am going to have to do some math here. Perhaps a Sum would work and I need to some how join the tables. The only thought I had was we need to join more than one table here. In the Inner Joins we had done in class it only related to two tables. I want three or all the tables perhaps to get the total data information for Vote Percentages.
40: Then I began thinking about that last one about Political Parties. I began comparing the ElectionsID, Party and Results Tables. I came up with a Theory which I did a webpage about. I feel like I am on to something, but now it is all a matter of putting it together.
41: It says on Oncourse that there is a formula that was given to us in class. I began going over the code of previous assignments we had done in class.
42: After looking at previous assignments such as Feb 20th Exercises, Login, fileReader, and Music Player I have came to the conclusion that the formula that we did in class that relates to this project can not be found.
43: With doing some research on-line and a friend's help I was able to pull off the by_pe.php and by_ped page. This is to show the Voting Percentages.
44: I discovered that you go about doing this in the same way we did the conveying of tables. We first must connect to the data base, we need to develop a query to select our data. Then we need to post that to a webpage for the user to see that information. You had to come up with a sum of the votes, invent new table columns that did not exsist in the original tables, etc. to output the data from the database.
45: To Be Continued ...