Tuesday, March 27, 2007

My Domain

My new domain: www.cbdmall.com
Right now, I direct it to my home ip, since I still cannot find a satisfactory host for my project. Maybe I should foward it to my VMWare if possible, that will make things much easier.

Monday, March 26, 2007

Bar Chart in PHP

I have learned a good example to display a bar chart in PHP, and I added a loop
statement, so the length of the bar can fit for the width of the browser.

Since the blog will filt a lot of html and PHP tags, I will pulish the final result in my online host. The main idea is to set the a table's cellpadding>=2, and then set bgcolor's length flexible to the cell in which a bar is displayed. In other word, the bgcolor length is directly propotional to the amount we defined.

Interesting css error with firefox

when make the body tag "float", everything mass up...... That's true
body cl*ss="interesting"

in css file:

interesting {
float: left;
}

guess what, the whole page's layout will be changed, especially padding and margin....
I have discussed this with Tim, but still don't know exactly the reason.

I guess this is a kind of bug in firefox when it tries to compile FLOAT tag

Sunday, March 25, 2007

PHP+PostgreSQL set up

I spend a whole weekend to work on LAPP. Just a little different from the popular term of "LAMP"(Linux+Apache+MySQL+PHP), 'cause mine is Linux+Apache+PHP+PostgreSQL :p

Here is the my install log for the whole staff (I set up a server in VMware, so I can check my results and fix bugs before submitting to a public server).

1. Download Ubuntu
2. Create a new ubuntu operation system in VMware, boot from Ubuntu6 iso file
3. After the system is done, use apt-get command or package management to install Apache2, PHP5, PostgreSQL8. The following additional modulates should be included:

  • OpenSSL: a SSL server enable me to login to the system from remote
  • install modulates: php5-mhash, php5-gd, php5-curl, php5-mhash, php5-pgsql, php5-xslt.

4. Configure PostgreSQL setting:

  • $useradd postgres
  • $chown -R postgres:postgres /etc/postgresql
  • $ sudo nano /etc/postgresql/8.1/main/pg_hba #add 127.0.0.1 to trust#
  • $ sudo -u postgres createuser -P #create the account and input name, passwd.... #
  • $ sudo -u postgres createdb test #create a db named test #
  • $ psql -U [username] test #log into test db if everything goes right#

5.Networking config

6 files are involved:

· /etc/hosts (signed computer name to IP address)
· /etc/networks (associate domain with IP address)
· /etc/sysconfig/network (open or close network, config computer name and gateway)
· /etc/resolv.conf (add DNS server IP)
· /etc/rc.d/rc3.d/S10network (as a wizard to activate the ethnet)
· /etc/sysconfig/network-scripts

Configure IP, directly edit /etc/network/interfaces,static IP can be edited as following:auto lo eth0iface lo inet loopbackiface eth0 inet staticaddress 192.168.2.2 netmask 255.255.255.0 broadcast 192.168.2.255 gateway 192.168.2.1

If assigned by DHCP, edit as: auto eth0iface eth0 inet

Command line is a better way:

ifconfig -a # display the network confi# ifconfig eth0 inet down #stop network # eth0ifconfig eth0 inet up 192.168.1.2 \netmask 255.255.255.0 broadcast 192.168.1.255 #config IP address netmask # add default gw 192.168.1.1 eth0 #gateway config#

When done, restart the networking: /etc/init.d/networking restart

6. Test web server

Change to the directory /var/www/ create a file, named info.php, add to it. Type the URL : 127.0.0.1/info.php in a browser, php config info will be displayed.

Create a file named pg_connect.php, add text:

//connect pgsql test//

$linkid = @pg_pconnect("host=localhost dbname=test user=postgre password=secret")

or die("Could not connect to the PostgreSQL server.");


$result= @pg_query("SELECT* FROM mytable") or die("The query failed");

//out put the result//

while($row=pg_fetch_object($result)) echo "No.$row->id is ($row->name)
";

?> # this will check PHP+PostgreSQL successuful or not #


7. Configure virtual host for different domain

/etc/apache2/sites-available/default is the default rule for domain root.
Add my own default domain config:
DomainName www.mydomain.com
DomainAdmin webmaster@mydomain.com
DomainRoot /anywhere I want/

If want to run more than one domain, I have do create a new file in the fold:
nano ./sites-available/newdomain
in the file, add another rules:

ServerName www.newdomain.com
ServerAdmin webmaster@newdomail.com
DocumentRoot "/another location you want/"
ErrorLog "/var/log/apache2/***_errors.log"
CustomLog "/var/log/apache2/***_accesses.log" common


When separate every domain config rule into a single file, we can just control the host very easily:
sudo a2ensite [rule.filename] to enable a domain
sudo a2 dissite [rule.filename] to disable a domain
don't forget to restart apache for new rules:
sudo /etc/init.d/apache2 restart


Wednesday, March 21, 2007

Power of CSS 2

#nav {
float: left;
width: 100%;
margin: 0;
padding: 10px 0 0 46px;
list-style: none;
background: #FFCB2D;
}
#nav li {
float: left;
margin: 0;
padding: 0;
font-family: "Lucida Grande", sans-serif;
font-size: 55%;
}
#nav a {
float: left;
display: block;
margin: 0 1px 0 0;
padding: 4px 8px;
color: #333;
text-decoration: none;
border: 1px solid #9B8748;
border-bottom: none;
}

This is a good example of combining usage of background and padding in "Bulletproof
Design". The author's method have avoided using big pictures, which will enhance the
page's scalability and flexibility.

Tuesday, March 20, 2007

Draft of Study Proposal

http://students.mim.iml.uts.edu.au/users/10530982/test.html

I also use the page as CSS practice field. So the style effect may change sometimes.

Monday, March 19, 2007

Power of CSS(1)

I used to create some simple web page by Macromedia's Dreamweaver. This powerful tool generates various CSS code with several simple clicks, so I never try to learn style design myself. But when I got this blog, I was desperate by the templates provided--the color, the frame width, the picture size definitions. Time to change this, also time to learn... Several days later, it looks like what you have seen now. I have adjusted every detail I didn't like... Also, some advanced skills can be learned in book "Bulletproof Web Design: Improving flexibility and protecting against worst-case scenarios with XHTML and CSS". It contains 10 cases about CSS application. I benefit a lot from the first three cases. Although I have not read though the book, but I wanna created a page using the methods it mentioned.

Combining use of Div Tags, Float, Padding and Margin, sometimes, would be an alternative to complex tables and forms that traditional web page design involved. But tables are still important elements in web pages, and some CSS on table would be useless if we overlook some pre-defined rules. Still, some seldom used tags in table do have their special features:
http://www.w3.org/TR/html401/struct/tables.html

Sunday, March 11, 2007

Draft of Draft for DMT Learning Proposal

I have spend a whole day to check my documents and figure out what I should learn in DMT course. I have great interest in e-commerce, which need DMT things a lot.

In fact, I should learn a lot about DMT, not just for the course, but just for my future. XHTML, PHP, SQL, Java Script, XML,... too many programming things I should learn. I used to like to learn from delicately planned lectures. In Tim's class, I smelt sth. different: I have to plan for myself.

I have read some books about HTML and CSS, but can hardly remember the tags' meaning. I have learned sth about PHP, but it is superficial, and I even didn't try to set a dynamic website for my own. I know sth about SQL, XML... but never use them in any on-hand practice. Finally, I got a picture of myself: what I need is to do some work really through my hands. And I aim to get familiar the whole development process from the very beginning.

It's said that PostgreSQL has all the all the modern db features. So I wanna have a try on it. Then I choose Apache+PHP+PostgreSQL on Linux as my publishing platform. I have collected some highly reccommended books/ebooks:



  1. Html,.Xhtml.And.Css.Bible


  2. Apress - Beginning PHP and PostgreSQL 8 From Novice to Professional


  3. Apress - Pro PHP XML and Web Services


  4. OReilly.PHP.Hacks.Tips.and.Tools.For.Creating.Dynamic.Websites

Going through these books won't be my aim. I just will do sth myself with these books. Regarding to my interest in e-commerce, I'd like to design a e-commerce web site realizing catalog and transation data retrieved from database.

bc4bc1bc2bc3

Thursday, March 8, 2007

JSP included by PHP

First, PHP manual should be downloaded from: http://de.php.net/download-docs.php

This official handbook is for all the people who want to learn php, from beginner to experienced PHP programmer. It covers everything!!

Here comes what I want to show you:

Funtionally, PHP is much like JSP. And JS can be included in a PHP file very easily. If you wanna create sth shining and simple, to add some little JS into you php page is a very good choice.

For example, I can simplily create a navigation menu by PHP maybe like this:
http://karlcore.com/programming/dynav/menu.phps
this is a good example to use an array to list everything we want to see. But don't you think it is too stiff or mechanical?

Here is a good way to create a drop-down menu with Java Script:
http://www.thesitewizard.com/archive/navigation.shtml
Let the navigation menu stay in good structure and make it a little bit cool! This simple Java Script can manage that.

Here is one more step before you can see your improved menu (in fact, it is also mentioned in the article), you need your PHP file to get into the Java Script and use it! Just simply use a 'include' function in PHP. JS will be parsed rightly into your php environment. Enjoy!