The stock market is a market on which shares -or small pieces of ownership- of publicly held companies are sold. Companies on the stock market are assigned a symbol and traded by brokers or investors. The valuation of each share of stock depends on a number of factors and the price of a stock goes up and down, sometimes every few seconds.

The stock market works in a manner similar to any other market. There are buyers and sellers. The buyers know how much they are wiling to pay and the sellers know how much they want to sell for. The buyers make an offer -called the "bid"- and the sellers list their price -called the "ask"- and then the actual price of the stock goes up and down in value.
Traditionally, stocks were sold on the trading floor of the New York Stock Exchange (NYSE). This meant that brokers were there, actually talking to each other and yelling out prices and exchanging shares of stock. Today, many stocks are sold electronically- investors and brokers can place trades through computer programs and software. In fact, one exchange, called the NASDAQ, is an entirely electronic exchange (the NYSE still has trades going on on the floor of the stock exchange).
Although the market works as most markets do, it is important to understand what is being sold on the market if you want to understand how does the stock market work.
Stocks are shares of ownership within a company. A company which is doing business may decide to go public, which means that it wants to issue stock to investors in order to raise funds or to make it easier for the company to be sold.
When the company goes public, it determines how much stock to sell. If it issues only 100 shares, then each share will represent a much larger ownership stake than if it issues 1,000 shares or 10,000 shares. It also determines an initial value for the stock. This process, called an initial public offering or IPO, involves extensive paperwork in which accounts prepare valuation statements and lawyers prepare legal information that is released to investors.
After a company goes public, it is given a symbol on whatever exchange it is on. For example, Apple Computer is called AAPL. When people want to buy a share of the company, they trade AAPL.
The initial price of a stock quickly changes. If people believe that he ownership interest in the company is worth more than the price a share was initially listed for, the price of the stock will go up. If people believe the company is worth less, the price of a share of stock will go down.
Even after the IPO, the price of stocks rarely remains fixed. The price is set based on investors perceived value of the company, and likewise of the ownership stake in it. If investors believe a company is likely to grow, expand and become more profitable, they will be willing to pay more for a share of stock. If investors believe a company is likely to do poorly, they will pay less.
In determining the worth of a stock -and thus setting its price- investors look at many factors. They consider the price to earnings ratio, which refers to how much the stock costs versus how much the company earns. They may also consider the return on equity -the amount of money the company made versus the amount of money the company spent. There are literally hundreds of different metrics used by sophisticated traders to decide what the price of a stock is worth.
The state of the economy and market as a whole also affects the price of a stock. If people believe that the country is entering a recession, the price of stocks may drop because the investors believe the companies will inherently be worth less. Likewise, if a certain industry- such as the technology sector- seems to be doing badly, all stock of technology companies could be hurt.
Investors also watch stock market indexes- such as the DOW Jones index- to determine how groups of stocks are doing.
You may be wondering about whether you should invest. Investing in stocks is often thought of as one of the best ways to grow your portfolio and to make money. However, it is also possible to lose money if you aren't careful.
If you want to invest in an individual stock, you need to make sure you do research about the company. You also shouldn't put all your eggs in one basket- or all your money in one stock. Buy several different stocks, in several sectors or industries, so you can be more protected if one doesn't perform (go up).
You can also invest in mutual funds where you put your money into a fund and an expert investment manager then adds that money to the cash that others put in and buys stocks with all of the money. You then earn the rewards if the stocks go up based on how much you put into the mutual fund. This can be a safe way of investing in stocks for those who haven't fully learned how to research the market or who don't have the time or interest in frequently watching the changing valuation of their stock.