Wednesday, January 23, 2008

Connection ADODB

Before a database can be accessed from a web page, a database connection has to be established.


Create a DSN-less Database Connection

The easiest way to connect to a database is to use a DSN-less connection. A DSN-less connection can be used against any Microsoft Access database on your web site.

If you have a database called "northwind.mdb" located in a web directory like "c:/webdata/", you can connect to the database with the following ASP code:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
%>

Note, from the example above, that you have to specify the Microsoft Access database driver (Provider) and the physical path to the database on your computer.


Create an ODBC Database Connection

If you have an ODBC database called "northwind" you can connect to the database with the following ASP code:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "northwind"
%>

With an ODBC connection, you can connect to any database, on any computer in your network, as long as an ODBC connection is available.


An ODBC Connection to an MS Access Database

Here is how to create a connection to a MS Access Database:

  1. Open the ODBC icon in your Control Panel.
  2. Choose the System DSN tab.
  3. Click on Add in the System DSN tab.
  4. Select the Microsoft Access Driver. Click Finish.
  5. In the next screen, click Select to locate the database.
  6. Give the database a Data Source Name (DSN).
  7. Click OK.

Note that this configuration has to be done on the computer where your web site is located. If you are running Personal Web Server (PWS) or Internet Information Server (IIS) on your own computer, the instructions above will work, but if your web site is located on a remote server, you have to have physical access to that server, or ask your web host to do this for you.


The ADO Connection Object

The ADO Connection object is used to create an open connection to a data source. Through this connection, you can access and manipulate a database.


Belajar JavaScript YUUUUUK

JavaSript Tutorial

Where do your JavaScript codes go? Well, basically anywhere inside the (html) tags of your page. The beginning of your code begins with (script type="text/javascript") and ends with (/script)

(html)
(head)(title)This is an example page(/title)(/head)
(body)
Welcome to the JavaScript course!
(script type="text/javascript")
(!--
document.write("Hi there. This text is written using JavaScript!")
//--)
(/script)
(/body)
(/html)

Output: Hi there. This text is written using JavaScript!

As you can see, we began our script with the tag (script language="type/javascript") The part in red is purely optional, as the browser by default assumes a (script) tag to be JavaScript, though you should include it nevertheless for validation reasons. The second and next to last lines of the above example are (!-- and //--), which are HTML comment tags tailored for JavaScript. It is recommended you include them to hide your code against very old browsers that don't support JavaScript. If you don't include them and someone is using such a browser, the browser will just "dump" all your code as text onto the screen, in other words, not a pretty sight! The only "functional part" of this script is the document.write(".......") part. It basically writes to the page whatever you put inside the quotation marks. Don't worry so much about why this is so yet, we will discuss this in detail later. We end this entire code with (/script) This terminates your script, and brings you back to html.

Like html, you can insert comments in your JavaScript codes. JavaScript comments are different from HTML comments, with the later commenting out certain lines within your script so they don't get interpreted. The syntax for JavaScript comments are:

//

for single-lined comments, or

/*
 
      */

for multiple ones.

For example:

(script language="JavaScript")
(!--
//this script does nothing and is useless!
/*
Hay, don't involve me
in this!
*/
//--)
(/script)

Ok, we are now ready to proceed to some real programming!

JavaScript, like many programming languages, relies on objects, functions, and event handlers to create workable programs. If you know absolutely nothing about these technical terms and how to use them, don't worry. By the time we're through with this tutorial, you will.

Thursday, January 17, 2008

Learn Smarty

The most common complaint that comes when a designer and a programmer are working together on the same project is that the output is mostly bugged. The reason for this is that the designer doesn't like too much funny symbols and characters in his HTML and tries to clear some of them. Erasing a single semicolon can cause a bunch of errors in PHP. This mostly results in arguments and blames. Yet on the other hand, it is important that the project is completed within the deadlines and hence we cannot seperate them from working together that easily. Lets see a few examples.


(html)
(head)
(title)
(?php
echo $title;
?)
(/title)
(/head)
(body)
(?php
echo "This is my first smarty example";
?)
(/body)
(/html)


The above example doesn't seem that bad. But trust me, when you start putting some complex pieces of code inside, it gets way too much messy.

Now lets start with some database queries.

(?php
//db configuration
include "config.php";

if(!($db = @mysql_connect($server, $db_user, $db_pass))) //connect to database
die("Couldn't connect to the database.");
if(!@mysql_select_db($db_name, $db)) //select database
die("Database doesn't exist!");

$sql = "SELECT * FROM users";

if(($result = @mysql_query($sql, $db)) == 0)
{
echo "\n(hr /)Database error: (span)".mysql_error()."(/span)(br/)\n";
die("MySQL Said: " . mysql_error());
}

$user = array();

?)
(table)
(tr)
(td)(b)Name(/b)(/td)(td)(b)Lastname(/b)(/td)
(/tr)
(?php
while($tmp = mysql_fetch_assoc($result))
{
?)
(tr)
(td)(?php echo $tmp["Name"];?)(/td)(td)(?php echo $tmp["Lastname"];?)(/td)
(/tr)
(?php
}
?)


The above code doesn't seem that messy because the HTML is still seperate from PHP (since we are not echoing it with PHP). Although the designer might still mess something if he is given this code to deal with. But this code doesn't seem that efficient when it gets bigger and bigger.
The general practice is that the programmer start echoing the HTML within PHP. Lets make the code a little easier with our own template system now.

(?php
//db configuration
include "config.php";

if(!($db = @mysql_connect($server, $db_user, $db_pass))) //connect to database
die("Couldn't connect to the database.");
if(!@mysql_select_db($db_name, $db)) //select database
die("Database doesn't exist!");

$sql = "SELECT * FROM users";

if(($result = @mysql_query($sql, $db)) == 0)
{
echo "\n(hr /)Database error: (span)".mysql_error()."(/span)(br/)\n";
die("MySQL Said: " . mysql_error());
}

$user = array();

while($tmp = mysql_fetch_assoc($result))
{
$user[] = $tmp;
}

include "templates/myTemplate.tpl.php";
?)


This is the basic PHP code.
Now this is the template PHP file which is mostly HTML.

(html)
(head)
(title)My Own Template System(/title)
(/head)
(body)
(table)
(tr)
(td)Name(/td)(td)Lastname(/td)
(/tr)
(?php
for($i=0; $i(count($user); $i++)
{
?)
(tr)
(td)(?php echo $user[$i]["Name"];?)(/td)(td)(?php echo $user[$i]["Lastname"];?)(/td)
(/tr)
(?php
}?)
(/table)
(/body)
(/html)


This way the designer is only concerned with this above file. He doesn't need to know how the base PHP is working.
He only needs to know some small details about PHP and he is good to go. Although There is a better way than this.

Using Smarty Template Engine


At first, like most PHP developers, I tried to stay away from this Template Engine because it was way too complex for me to understand and the necessary files that i though it used to create. Although as time passed, I realized, it gets really hard to code you own template engine as good as Smarty. In the next example I will show you how to convert MyFirstTemplate to work with Smarty.
First of all, download the latest version of Smarty Template Engine . Once you downloaded it, extract it into the temporary dir.
Next thing to do is to setup all directories and files Smarty needs. It requires templates, templates_c, cache and configs directories. Templates dir should be used to place templates you create, templates_c is directory is for complied templates, cache for cached templates and configs for config files. However, you can name them however you want, but make sure you tell Smarty that. I created one more directory named smarty, where you should copy libs directory which comes along with archive you just downloaded.

At this point, you should have structure of your future web application like this:

- [cache]
- [configs]
+ [smarty]
- [libs]
- [templates]
- [templates_c]

Make sure to make templates_c and cache directory writable by your web server. You can do this be setting their CHMOD to 755 or 777, which ever your server

allows.
I have created a config file which will contain some basic configuration such as database info as well as some code which will be used for initializing

Smarty.

Here is the code within config.php file:

(?php

//db configuration
$server = "localhost";
$db_user = "root";
$db_pass = "password";
$db_name = "myFirst";


require_once("smarty/libs/Smarty.class.php");
$smarty = new Smarty;

?)

Now lets change our First Template with Smarty.

(?php
//db configuration
include "config.php";

if(!($db = @mysql_connect($server, $db_user, $db_pass))) //connect to database
die("Couldn't connect to the database.");
if(!@mysql_select_db($db_name, $db)) //select database
die("Database doesn't exist!");

$sql = "SELECT * FROM users";

if(($result = @mysql_query($sql, $db)) == 0)
{
echo "\n(hr /)Database error: (span)".mysql_error()."(/span)(br/)\n";
die("MySQL Said: " . mysql_error());
}

$user = array();

while($tmp = mysql_fetch_assoc($result))
{
$user[] = $tmp;
}

$smarty-)assign("title", "My First Template with Smarty");
$smarty-)assign("user", $user);
$smarty-)display("myFirstExample.tpl.htm");
?)


All we added was the last three lines of code.
Basically what we are doing here is that we are assigning some values to the variables we will use in our HTML template.
$smarty is the constructor variable. You can make your own with changing the config line "$smarty = new Smarty;" to $youVar = new Smarty;"

The last line of code tells Smarty to use this ("myFirstExample") file as the template.

The myFirstExample.tpl.html looks something like.

(html)
(head)
(title){$title}(/title)
(/head)
(body)
(table)
(tr)
(td)No(/td)
(td)Name(/td)(td)Lastname(/td)
(/tr)
{section name=i loop=$user}
(tr)
(td){$smarty.section.i.iteration}(/td)
(td){$user[i].Name}(/td)(td){$user[i].Lastname}(/td)
(/tr)
{/section}
(/table)
(/body)
(/html)


The advantage we got is that now we can preview our HTML code on the browser directly, and when we run it with PHP, it will work as it should.

The major change that you must have noticed is.

{section name=i loop=$user}
(tr)
(td){$smarty.section.i.iteration}(/td)
(td){$user[i].Name}(/td)(td){$user[i].Lastname}(/td)
(/tr)
{/section}


{section} is for a looping over arrays of data and each of section tags must be followed by closing tag {/section}. {section} tag requires only two

attributes: name and loop. Name attribute is a name of the section and loop is a value to determine the number of loop iterations. However, {section} has

other optional attributes such as start, stop, max, show.
{section} also has its own variables which handle section properties. One of them I used to show the number of iteration is echoed with

{$smarty.section.i.iteration}.
Also, you are able to nest sections within sections, however, make sure that you name those differently.

This is it, Smarty in some basic action. This code only shows how to install and use some basic options. There is so much to smarty, and I will try to show

you how to use modifiers, write your own and to take advantage of everything smarty offers.
I hope this was useful and you wouldn't need to code your own template engine for every application you make.

Tuesday, January 1, 2008

Sell Product

How to Sell a Product to Retailers
The aim of this information sheet is to assist businesses who have a product to sell to consumers through
retailers.
The information sheet was researched and written by SBCS counsellors John Treverton and Frank Clutton
and Office of Small Business Project Manager Geoff Lee. Both John and Frank spent most of their
careers selling to retailers. Retail buyers were consulted extensively in the preparation of this
information sheet as were the proprietors of small businesses who have successfully sold products to
retailers.
The SBCS is a non-profit organisation providing experienced volunteer business counsellors, mentors and
coaches to Victorian businesses. The objective of the SBCS and its counsellors is to improve the
employment potential, sales and profits of Victorian businesses for the benefit of the whole community.
The service is available through the Department of Innovation, Industry & Regional Development – Office
of Small Business.
Approaching and successfully marketing a product through a retailer can be achieved in four basic steps:
1. Preparation for the interview with a retail buyer.
2. Obtaining an appointment to see an appropriate buyer.
3. The sales presentation.
4. After-sales service.
1. PREPARATION FOR THE INTERVIEW WITH A RETAIL BUYER
Proper and comprehensive research and preparation before the interview will almost guarantee a sale.
When a detailed Marketing Plan has been carried out, preparing for an interview with a retail buyer will be
comparatively simple because the following vital issues will have already been addressed:-
1. The product sample will be complete in every detail.
2. The product will have met all Federal, State, and local Government legislative and regulatory
standards.
3. The product colours, sizes and packs will have been finalised.
4. The product will have been market researched and consumer tested and the results documented -
this can be a great help in overcoming a retail buyer’s ‘objections’.
It is absolutely critical that you know from this research the criteria that both the end-user and
the retailer use to decide on which product to buy.
Market research can be D.I.Y. - but may not be as credible in the retailer’s eyes as independent
research.
5. The unique benefits and selling points of the product will have been ascertained.
6. The competitive advantages of the product will have been fully identified - this requires a
thorough
knowledge of competitors’ products.
7. The market segment to which the product is aimed will have been defined, and its size estimated
(eg. how many potential buyers?)
8. Advertising and promotion plans will be available.
9. Point of sale material will have been developed.
10. EAN numbers (bar codes) will have been applied for.
11. A decision will have been made as to the category of retailer to which the product is best suited:
eg. independents, supermarket/chain stores, buying groups, wholesalers, franchisors, etc.
12. The product will have been identified as being: budget, middle of the road, up-market or
exclusive in terms of price, quality and value.
13. Prior knowledge will also have been gained as to the buying patterns of the selected retailer, with
due regard to seasonality and special events.
14. The retailer’s ability to pay, and the time taken to pay, will have been determined from trade
referees and/or a credit checking service; do not assume strong solvency no matter how large the
retailer.
15. Background information on the retailer's operation will also have been researched, particularly
with regard to their specific trading terms and conditions, in-store policies and layouts.
16. Your costing and pricing strategy will have been decided - see below.
COSTING:
All costs, including the ‘hidden’ costs, must be fully identified before a price is set, and before the sales
presentation. Failure by the supplier to identify all costs before the sales presentation often leads to
underpricing of the product and this can lead to low or non existent profitability. Research the following
items for inclusion in your costing:
Contributions and Charges:
It is the usual practice of the larger retailers to insist on certain financial contributions and discounts as
well as receiving their retail mark-up. The additional financial contributions will vary between retailers.
Typical fees and charges are:
. Line fees (to have the product listed).
. Warehouse fees (covers the cost of distribution to branches).
. Shelf space fees (for permanent shelf space in all stores).
. Promotion fees (to offset costs of in-store display material).
. Wastage fees (to offset general wastage).
. Settlement fees (a discount for prompt payment by the retailer).
. Catalogue fees (for the product to be listed in a special offer sales sheet).
. Co-operative advertising in seasonal brochures will also be an expected contribution.
In most cases fees are based on a percentage of the annual turnover of the product but some are levied
on a one-off basis. All, of course, can be subject to negotiation.
Note: If the retailer is not really interested in your product, perhaps because they expect sales will be
too low, or that the profitability is not high enough, or they already have similar products that they are
happy with, they may ask you for an exorbitant Line Fee of say $50,000. This is intended to dissuade you
from persisting, but it enables them to avoid having to say “No” directly to your face.
Delivery costs:
All retailers will expect delivery on an FIS (free into store) basis, which means that the supplier is
responsible for the freight and insurance charges on the goods until they are unloaded and signed for at
the retailer's premises. Some retailers will only accept goods which are on pallets.
Penalties:
Continuity of supply is paramount to a retailer and the supplier's awareness of delivery complications is
vital, especially if interstate transport is involved. In some cases a penalty is imposed by the retailer if
goods arrive late or are short supplied.
Returns:
Most retailers have a returns policy whereby damaged or surplus stock is returned to the supplier at the
supplier's expense.
Bar Codes:
Virtually all retailers require all product to be bar coded. Only shops which are not computerised will
accept goods without an EAN number. EAN numbers are issued by EAN AUSTRALIA for an initial and
annual fee. Some retailers will also require a TUN number, which is displayed on transit outers.
Merchandising:
Many retailers also expect the supplier to keep stock tidy in the store, to take stock on a regular basis,
and to place orders for the retailer, sometimes via on-line links to the retailer’s computer.
PRICING:
A pricing strategy should be decided in advance e.g. cost plus, or what the market will bear, and you must
know your bottom-line price. Be aware that more and more retailers are asking suppliers to reduce their
real wholesale price over a period of time. This can be taken into account when initially pricing the product
and/or by achieving lower costs through future efficiency.
The Retailer’s Mark-Up:
It is not absolutely essential to know what mark-up might be applied by the retailer if you know what your
pricing strategy and “bottom-line” price is. Nevertheless, many retailers will give suppliers an indication as
to the mark-up they expect before the sales presentation. Remember that you cannot legally tell the
retailer what to charge. Mark-ups can vary from 2% to 100+% on the wholesale price depending on the
type of product, retailer’s strategy and economic conditions.
THE SALES PRESENTATION FOLDER:
The final stage of preparation is the creation of a Sales Presentation Folder.
This ensures that all aspects such as, the target market, the market research, consumer test results,
consumer benefits, advertising and promotional plans of the product are presented to the buyer in the
correct sequence and with the correct emphasis. Each page of the folder should cover one aspect relevant
to the product. By taking each aspect in turn and obtaining the buyer's agreement stage by stage, any
likelihood of negativity from the buyer is reduced.
It is of course important to talk about the ‘features’ or ‘characteristics’ of your product, but these must
then be clearly linked to the ‘benefit’ of that ‘feature’ or ‘characteristic’ to the end consumer. For
instance a feature of a Compact Disc Player may be that it has ‘skip track’. Do not assume that the buyer
will automatically understand the benefit of this feature (skip track). You must point out that the benefit
to the consumer is that they do not have to listen to tracks that they do not like every time they play
that CD! Sellers often make the mistake of talking only about features and not the benefits – and hence
they fail to make a sale!
When this essential 'homework' has been completed, the product should be 'market ready' and an
approach to a retailer can be made.
2. OBTAINING AN APPOINTMENT TO SEE AN APPROPRIATE BUYER
The first contact with a retail organisation is usually by telephone. Unless an approach is being made to a
small independent retailer, it is unlikely that a buyer will answer directly, and that the first contact will be
with a receptionist.
The receptionist is able to direct an enquiry to the appropriate buyer when it has been made clear to
which precise category the product belongs. It is important to request the name and title of the buyer to
whom the product will be presented before being transferred to the buyer or relevant department.
Be aware that a screening procedure may be in operation to prevent immediate contact with the buyer,
but it is usually possible to make an appointment. It is important that the appointment is made with the
decision maker and not a deputy, who does not have the authority to buy.
Do not try to discuss the product, or any aspect of it, over the telephone. Remember that the purpose of
the call is to get an appointment to see the buyer.
Examples of appointment making phrases are:-
􀂈 "We have an interesting product opportunity which we would like to discuss with you"
􀂈 "We have a product opportunity to attract new customers to your stores and would like to show
it to you"
􀂈 "We would like to show you a unique product, ideally suited to (store name), and would like an
appointment to discuss it"
If pressed to be specific about the product before an interview will be granted, endeavour to emphasise
that the product needs to be seen (touched, smelt, tasted or applied) because it is new and different and
that is the reason an appointment is necessary. Care is needed to avoid a possible response that the
retailer has sufficient of the type of product being offered and that no more are required. For example:
If the product were a nail-gun, a better description, when endeavouring to obtain an appointment, might
be "a special device for knocking in nails".
3. THE SALES PRESENTATION
It is important to arrive on time for the interview and that the sample of the product is perfect and
exactly as it will be supplied. The Sales Presentation Folder, together with all documentation on market
research and written consumer test results, must be readily available.
The sample should be in a case or wrapped, so that it is not immediately visible to the buyer. The purpose
of this approach is to get the buyer's positive interest before showing the product and thus avoid thepossibility of a negative decision being made without first having some relevant information.
Therefore on this first visit, make introductions pleasant but formal, avoid 'small talk' and begin by
providing a short background of the product's development, its competitive edge, and main product
benefits using the Sales Presentation Folder.
When the buyer has been made aware of these facts THEN show the product to the buyer and reinforce
the consumer benefits, which will have been outlined a few moments before.
Continue by presenting the market research results, indicate the target market and discuss advertising
and promotion plans and possibly offer exclusivity for a limited period.
Listen to what the buyer is saying, answer the buyer's questions and dispel buying objections positively.
Overcoming Objections:
One accepted method to use to overcome buying objections and to dispel doubts in the buyer’s mind is the
“Yes-But " technique.
This means that when an objection is raised, such as, “too expensive, not enough demand, wrong colour,
wrong style, not as good as current stock” etc., the answer of "Yes-But," followed by the re-emphasising
of the unique consumer benefits of the product and the market research results (refer 1.4) helps to
negate the objection. It is vitally important to always emphasise the unique consumer benefits and market
research results and not the 'technical’ details of a product when presenting a product to a buyer.
Whilst the retail buyer may not tell you directly to your face, they may not want to stock your product
because it is a single product e.g. some toe socks. Nevertheless, they may be interested in your socks if
they are part of a line or range comprising socks, gloves and a scarf, etc. Therefore, you may need to
develop a range or line of products to make a successful sale.
Asking for the Order and Closing the Sale:
Once the buyer’s objections, if any, have been overcome the sale must be closed eg. “How many can I book
for you?” or “When would you require delivery?”
Much will depend on the type of product and buying practice of the retail organisation as to whether a
firm commitment to buy will be given at the time of the first interview. It may be that a buying
committee has to be involved, and if it is not permissible for a presentation to be made personally, then a
copy of the Sales Presentation Folder should accompany the sample for the buying committee's
consideration. When the commitment is given, remember, it will be subject to rigorous terms and
conditions set out by the retailer (see Costing and Pricing above).
Initial acceptance is usually for a trial period, for example 3 months, in which time consumer acceptance
will be assessed.
Small business suppliers should be aware that large retailers may not want to buy direct in small quantities
so they may refer you to a broker or wholesaler so that the retailer’s purchases can be consolidated.
4. AFTER SALES SERVICE BY THE SUPPLIER
All retailers will expect an after-sales service from a supplier. This can be as minimal as a regular
telephone call and occasional visit to a single small independent retailer, or as complex as the supply of a
merchandising force visiting every branch of a large retailer on a daily basis. However large or small this
operation will be, its purpose is to assist the sales of the product to the consumer. Competition is fierce in
the market place, with each supplier making sure that his or her product is displayed to maximum
advantage and that the product condition is perfect. Technical support, advice and motivation of the retail
staff is also essential. Every competitive supplier to the retail trade is involved in applying their utmost
effort to ensuring that their product sells. The newer the product, the more essential this activity
becomes.
IN SUMMARY
When offering a product to a buyer, remember the buyer's criteria:
􀂈 What appeal has this product to the consumer?
􀂈 Why will consumers buy the product?
􀂈 Where does it fit into the range currently stocked?
􀂈 Who are the competitors?
􀂈 Does it show sufficient profit?
􀂈 How will it be displayed?
􀂈 How is it to be advertised and promoted?
􀂈 What are the pack sizes?
􀂈 Is the continuity of supply secure?
􀂈 What after-sales service is available?
Remember also:
􀂈 Retailers are "middlemen" between suppliers and consumers and their objective is to generate the
maximum dollar profit per square metre of available selling space. If your product can generate
more dollars per square metre than an existing product you will displace them – and vice versa!
􀂈 Retailers are not particularly interested in whose product they sell.
􀂈 It is the supplier’s responsibility to ensure that consumers choose their product.
Success is assured with careful planning, awareness and research of the retailer’s terms and conditions, a
structured sales presentation and strong after-sales service.
SBCS counsellors can help you to prepare your sales presentation and they can help you to rehearse
it. This will maximise your likelihood of succeeding for less than $100-00.
If you would like help from a counsellor either call 132 215, visit the SBCS website www.sbcs.org.au where
you can choose a counsellor or just send an email to businessimprovement@iird.vic.gov.au
This information sheet was researched and written by SBCS counsellors John Treverton and Frank
Clutton with the assistance of Geoff Lee, Project Manager, Department of Innovation, Industry &
Regional Development – Office of Small Business.
COPYRIGHT SBCS Inc.

About Marketing

Marketing

From Wikipedia, the free encyclopedia



Marketing is a societal process that is needed to discern consumers' wants; focusing on a product/service to those wants, and to mould the consumers towards the products/services. Marketing is fundamental to any businesses growth. The marketing teams (Marketers) have the task to create the consumer awareness of the products/services through marketing techniques; if a business does not pay attention to their products/services and their consumers' demographics, the business would not be able to endure longevity.

Marketing tends to be seen as a creative industry, which includes advertising, distribution and selling. It is also concerned with anticipating the customers' future needs and wants, often through market research.

Its specialist areas include: