Category Archives: PHP and MY sql

Bootrap Jumbotron into WordPress Theme

In this post I will use a bootstrap Jumbotron template,here is the link http://getbootstrap.com/examples/jumbotron/  I will  customize it into wordpress theme

You need download bootstrap into” yourtheme “folder, whatever theme name you like to call it.

bootstrap_to_wordpress2

 

Those fold should inside your theme folder, don’t worry what are inside it except everything from bootstrap, the other file is empty now.

1) for wordpress could read you theme you need put those on top of your style.css:

/*
Theme Name: Bootstrap to WordPress
Theme URI: http://sandywebdesigner.com
Author: Sandy Zhang
Author URI: http://sandywebdesigner.com
Description: Example theme for  how to convert static Bootstrap site into dynamic WordPress theme
Version: 1.0
License:
License URI:
Text Domain: bootstrap-to-wp

This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you’ve learned with others.
*/

/* Move down content because we have a fixed navbar that is 50px tall */
body {
padding-top: 50px;
padding-bottom: 20px;
}
.admin-bar .navbar-fixed-top {
margin-top: 30px;
}
/* Below is the style for navigation in functions.php add a class to sub-menu to the navigation so I just write a simple style to it,you could customize it by yourself */
@media (min-width:768px) {
.sub-menu {
display: none;
position: absolute;
background: #222;
padding: 10px 15px;
width: 150px;
}

li:hover .sub-menu {
display: block;
}

}

.sub-menu li {
margin-bottom: 10px;
list-style: none;
}

.sub-menu li:last-child {
margin-bottom: 0;
}

.sub-menu a  {
color: #999;
text-decoration: none;
}

.sub-menu a:hover  {
color: #fff;
}

.current-menu-item > a, .current-menu-parent > a {
background: #000;
}
.current-menu-parent li a {
background: inherit;
}
.current-menu-parent .current-menu-item a {
color: #fff;
font-weight: bold;
}

.sidebar{
margin-top:40px;
color:#444;
}
.sidebar h3{
color:#888;
}
.widget{
margin:10px 0 30px;
}
article .post{
margin:20px 0;
}

.featured-image img,
.portfolio-piece img,
.portfolio-image img {
max-width:100%;
}

.prev-next{
font-size:24px;
margin-top:30px;
text-align:right;
}

@media (max-width:540px) {
.portfolio-piece h4{
font-size:.8em;
}
.prev-next{
font-size:15px;
margin-top:15px;
text-align:right;
}

}

2)header.php

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset=”<?php bloginfo( ‘charset’ ); ?>”>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<link rel=”shortcut icon” href=”<?php bloginfo(‘template_directory’);?>/images/favicon.ico”>

<title>
<?php wp_title(‘|’,true,’right’);?>
<?php bloginfo(‘name’)?>

</title>

<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>

<div class=”navbar navbar-inverse navbar-fixed-top” role=”navigation”>
<div class=”container”>
<div class=”navbar-header”>
<button type=”button” class=”navbar-toggle” data-toggle=”collapse” data-target=”.navbar-collapse”>
<span class=”sr-only”>Toggle navigation</span>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
</button>
<a class=”navbar-brand” href=”<?php bloginfo(‘url’); ?>”><?php bloginfo(‘name’); ?></a>
</div>
<div class=”navbar-collapse collapse”>
<?php
$args = array(
‘menu’ => ‘mainmenu’,
‘menu_class’ => ‘nav navbar-nav’,
‘container’ => ‘false’
);
wp_nav_menu($args);
?>
</div><!–/.navbar-collapse –>
</div>
</div>

3)footer.php

<hr>

<footer>
<p>&copy; <?php bloginfo(‘name’);?> <?php echo date(‘Y’); ?></p>
</footer>
</div> <!– /container –>
<?php wp_footer(); ?>
</body>
</html>

3)index.php

<?php get_header(); ?>

<div class=”container”>

<div class=”row”>
<div class=”col-md-9″>
<?php if(have_posts()):while(have_posts()):the_post();?>
<div class=”Page-header”>
<h1><?php the_title(); ?></h1>
</div>
<?php the_content();?>
<?php endwhile; else:?>

<div class=”Page-header”>
<h1>Oh no!</h1>
</div>
<p>No content is appearing for this page!</p>
<?php the_content();?>

<?php endif;?>

</div>
<?php get_sidebar(); ?>

</div>

<?php get_footer(); ?>

4)functions.php

<?php
function theme_styles(){
wp_enqueue_style( ‘bootstrap_css’, get_template_directory_uri() . ‘/css/bootstrap.min.css’ );
wp_enqueue_style( ‘main_css’, get_template_directory_uri() . ‘/style.css’ );
}
add_action( ‘wp_enqueue_scripts’, ‘theme_styles’ );

function theme_js(){
global $wp_scripts;
wp_register_script( ‘html5_shiv’, ‘https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js&#8217;, ”, ”, false );

wp_register_script( ‘respond_js’, ‘https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js&#8217;, ”, ”, false );

$wp_scripts->add_data( ‘html5_shiv’, ‘conditional’, ‘lt IE 9’ );
$wp_scripts->add_data( ‘respond_js’, ‘conditional’, ‘lt IE 9’ );
wp_enqueue_script( ‘bootstrap_js’, get_template_directory_uri() . ‘/js/bootstrap.min.js’, array(‘jquery’), ”, true );
wp_enqueue_script( ‘theme_js’, get_template_directory_uri() . ‘/js/theme.js’, array(‘jquery’,’bootstrap_js’), ”, true );

}

add_action( ‘wp_enqueue_scripts’, ‘theme_js’ );

add_theme_support(‘menus’);
add_theme_support(‘post-thumbnails’);

function register_theme_menus() {
register_nav_menus(
array(
‘header-menu’    => __( ‘mainmenu’ )
)
);
}
add_action( ‘init’, ‘register_theme_menus’ );

function create_widget( $name, $id, $description ) {

register_sidebar(array(
‘name’ => __( $name ),
‘id’ => $id,
‘description’ => __( $description ),
‘before_widget’ => ‘<div class=”widget”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’
));
}

create_widget( ‘Front Page Left’, ‘front-left’, ‘Displays on the left of the homepage’ );
create_widget( ‘Front Page Center’, ‘front-center’, ‘Displays in the center of the homepage’ );
create_widget( ‘Front Page Right’, ‘front-right’, ‘Displays on the right of the homepage’ );
?>

See how simple it is, index.php you completed, then use this index.php to create other template like page.php. single.php, etc. Have fun!

 

 

 

 

 

 

Customize WordPress Theme: Make header.php and footer.php — Part 2

<?php get_header();?>

<?php get_footer();?>

<?php get_sidebar();?>

Header.php meta change:

    <title><?php wp_title(”); ?><?php if(wp_title(”, false)) { echo ‘ | ‘; } ?> <?php bloginfo(‘name’); ?></title>    
    
    <meta http-equiv=”Content-Type” content=”text/html; charset=<?php bloginfo( ‘charset’ ); ?>” />

 

here is the why I said in the previous post why the categories is so important, in here you could use this in your header.php to pull out it as you navigation:

<?php
    $args=array(
      ‘orderby’ => ‘id’,
      ‘order’ => ‘ASC’
      );
    $categories=get_categories($args);
      foreach($categories as $category) {
        echo ‘<li class=”thisclass”><a href=”‘ . get_category_link( $category->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $category->name ) . ‘” ‘ . ‘>’ . $category->name.'</a></li>’;
        }
    ?>

 

Zend Framework2: Tutorial Part4: Building a CRUD app by using Table Gateway2

 Here you have your form fold, the file stuction should look like this:

crud4

here is the code for userForm.php

<?php
namespace CsnUser\Form;

use Zend\Form\Form;

class UserForm extends Form
{
public function __construct($name = null)
{
parent::__construct(‘user’);
$this->setAttribute(‘method’, ‘post’);

$this->add(array(
‘name’ =>’usr_name’,
‘attributes’=> array(
‘type’=>’text’,
),
‘options’=>array(
‘label’=>’Username’,
),
));

$this->add(array(
‘name’ =>’usr_password’,
‘attributes’=> array(
‘type’=>’password’,
),
‘options’=>array(
‘label’=>’Password’,
),
));

$this->add(array(
‘name’ =>’usr_email’,
‘attributes’=> array(
‘type’=>’email’,
),
‘options’=>array(
‘label’=>’E-mail’,
),
));

$this->add(array(
‘name’ =>’usrl_id’,
‘type’=>’Zend\Form\Element\Select’,
‘options’=>array(
‘label’=>’Role’,
‘value_options’=>array(
‘1’=>’Public’,
‘2’=>’Member’,
‘3’=>’Admin’,
),
),
));

$this->add(array(
‘name’ =>’lng_id’,
‘type’=>’Zend\Form\Element\Select’,
‘options’=>array(
‘label’=>’Language’,
‘value_options’=>array(
‘1’=>’English’,
‘2’=>’French’,
‘3’=>’German’,
),
),
));

$this->add(array(
‘name’ =>’usr_active’,
‘type’=>’Zend\Form\Element\Select’,
‘options’=>array(
‘label’=>’Active’,
‘value_options’=>array(
‘0’=>’No’,
‘1’=>’Yes’,

),
),
));

$this->add(array(
‘name’ =>’usr_question’,
‘attributes’=> array(
‘type’=>’text’,
),
‘options’=>array(
‘label’=>’Question’,
),
));

$this->add(array(
‘name’ =>’usr_answer’,
‘attributes’=> array(
‘type’=>’text’,
),
‘options’=>array(
‘label’=>’Answer’,
),
));

$this->add(array(
‘name’ =>’usr_picture’,
‘attributes’=> array(
‘type’=>’text’,
),
‘options’=>array(
‘label’=>’Picture URL’,
),
));

$this->add(array(
‘name’ =>’usr_picture’,
‘attributes’=> array(
‘type’=>’text’,
),
‘options’=>array(
‘label’=>’Picture URL’,
),
));

$this->add(array(
‘name’ => ‘usr_password_salt’,
‘attributes’ => array(
‘type’  => ‘text’,
),
‘options’ => array(
‘label’ => ‘Password Salt’,
),
));

$this->add(array(
‘name’ => ‘usr_registration_date’,
‘attributes’ => array(
‘type’  => ‘text’,
),
‘options’ => array(
‘label’ => ‘Registration Date’,
),
));

$this->add(array(
‘name’ => ‘usr_registration_token’,
‘attributes’ => array(
‘type’  => ‘text’,
),
‘options’ => array(
‘label’ => ‘Registration Token’,
),
));

$this->add(array(
‘name’ => ‘usr_email_confirmed’,
‘type’ => ‘Zend\Form\Element\Select’,
‘options’ => array(
‘label’ => ‘E-mail was confirmed?’,
‘value_options’ => array(
‘0’ => ‘No’,
‘1’ => ‘Yes’,
),
),
));

$this->add(array(
‘name’ => ‘submit’,
‘attributes’ => array(
‘type’  => ‘submit’,
‘value’ => ‘Go’,
‘id’ => ‘submitbutton’,
),
));
}
}

here is the code for userFilter.php(you could use javascript like backbone to validate the form instead will more faster)

<?php
namespace CsnUser\Form;

use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;

class UserFilter extends InputFilter
{
public function __construct() {
$this->add(array(
‘name’=>’usr_name’,
‘required’=>true,
‘filters’=>array(
array(‘name’=>’StripTags’),
array(‘name’=>’StringTrim’),
),
‘validators’=>array(
array(
‘name’    => ‘StringLength’,
‘options’ => array(
‘encoding’ => ‘UTF-8’,
‘min’      => 1,
‘max’      => 100,
),
),
),
));

$this->add(array(
‘name’       => ‘usr_email’,
‘required’   => true,
‘validators’ => array(
array(
‘name’ => ‘EmailAddress’
),
),
));

$this->add(array(
‘name’     => ‘usr_password’,
‘required’ => true,
‘filters’  => array(
array(‘name’ => ‘StripTags’),
array(‘name’ => ‘StringTrim’),
),
‘validators’ => array(
array(
‘name’    => ‘StringLength’,
‘options’ => array(
‘encoding’ => ‘UTF-8’,
‘min’      => 6,
‘max’      => 12,
),
),
),
));

$this->add(array(
‘name’     => ‘usr_active’,
‘required’ => true,
‘filters’  => array(
array(‘name’ => ‘Int’),
),
‘validators’ => array(
array(
‘name’    => ‘Digits’,
),
),
));

}

}

the index.phtml code:for retrieve data from your database, here is your presentation page, on you browser type:http://zf2.local/csn-user/user/index

should look like this:

crud3

 

<h1>Index = Retrieve</h1>
<a href=”<?php echo $this->url(‘csn_user/default’, array(‘controller’ => ‘user’, ‘action’ => ‘create’)); ?>”>Create</a>
<table>
<tr>
<th>usr_id</th>
<th>usr_name</th>
<th>usr_email</th>
</tr>
<?php
foreach ($rowset as $row) {
?>
<tr>
<td><?php  echo $row->usr_id; // The row is an ArrayObject $row->usr_id and $row[‘usr_id’] with both work?></td>
<td><?php  echo $row[‘usr_name’]; ?></td>
<td><?php  echo $row[‘usr_email’]; ?></td>
<td><a href=”<?php echo $this->url(‘csn_user/default’, array(‘controller’ => ‘user’, ‘action’ => ‘update’, ‘id’ => $row[‘usr_id’])); ?>”>Edit</a></td>
<td><a href=”<?php echo $this->url(‘csn_user/default’, array(‘controller’ => ‘user’, ‘action’ => ‘delete’, ‘id’ => $row[‘usr_id’]));?>” onclick=”return confirm(‘Do you rely want to delete the record?’)”>Delete</a></td>
</tr>
<?php
}
?>
</table>

your update.phtml code:

<h1>Update</h1>
<?php
$form = $this->form;
$form->prepare();
$form->setAttribute(‘action’,$this->url(‘csn_user/default’, array(‘controller’ => ‘user’, ‘action’ => ‘update’, ‘id’ => $id)));
$form->setAttribute(‘method’,’post’);

echo $this->form()->openTag($form);
echo $this->formCollection($form);
echo $this->form()->closeTag();

your create.phtml code:

<h1>Create an new user</h1>
<?php
$form = $this->form;
$form->prepare();
// Assuming the “contact/process” route exists…
$form->setAttribute(‘action’, $this->url(‘csn_user/default’, array(‘controller’ => ‘user’, ‘action’ => ‘create’))); //’contact/process’));
// Set the method attribute for the form
$form->setAttribute(‘method’, ‘post’);

echo $this->form()->openTag($form);
echo $this->formCollection($form);
echo $this->form()->closeTag();

And you don’t need a delete view

 

Zend Framework2: Tutorial Part4: Building a CRUD app by using Table Gateway1

The previous post I already wrote how to add a references to the databases connection, this post I will tell you how to building a CRUD app.

First, create a new module named “CsnUser”, or just copy the entire “Application” fold, and change the name to “CsnUser” .

then you file struction should look like this.

crud1

Second, go to open your Module.php

Here is the code:inside it quick just standard proceed, just tell where is the config file and  the namespace’s path.

<?php

namespace CsnUser;//this namespace must match your module’s name

class Module
{
public function getConfig()
{
return include __DIR__ . ‘/config/module.config.php’;
}

public function getAutoloaderConfig()
{
return array(
‘Zend\Loader\StandardAutoloader’ => array(
‘namespaces’ => array(
__NAMESPACE__ => __DIR__ . ‘/src/’ . __NAMESPACE__,
),
),
);
}

}

Continue reading Zend Framework2: Tutorial Part4: Building a CRUD app by using Table Gateway1

Zend Framework2: Tutorial Part3 use TableGateway add references to the database connection

Just go to modify “config/autoload/global.php”

return array(
‘db’ => array(
‘driver’ => ‘Pdo’,
‘dsn’ => ‘mysql:dbname=test;host=localhost’,
‘username’ => ‘db_user’,
‘password’ => ”,
‘driver_options’ => array(
PDO::MYSQL_ATTR_INIT_COMMAND => ‘SET NAMES \’UTF8\”
),
),
‘service_manager’ => array(
‘factories’ => array(
‘Zend\Db\Adapter\Adapter’
=> ‘Zend\Db\Adapter\AdapterServiceFactory’,
),
),
);

Cakephp Blog Tutorial 1 – Installation

1. download the latest version cakePHP,

2. copy into localhost root file, and I name it as “Blog”

3. There are 3 things need to fix it out:

First is connect to your databases:

A) Database configuration (make sure have a  database in your localhost)

B) use NetBeans to open your files,under the App file, under config file, you see a database.php.default,rename it and move .default, and open it

C) here you could set your database, there are class you should change it like this

public $default = array(
‘datasource’ => ‘Database/Mysql’,
‘persistent’ => false,
‘host’ => ‘localhost’,
‘port’ => ”,
‘login’ => ‘root’,//I use localhost, so I set it root
‘password’ => ‘*******’,//here put your password
‘database’ => ‘blog’,//choose your databases
‘prefix’ => ”,
‘encoding’ => ‘utf8’,
);

Second,config your salt

under app/config/core.php, open core.php file,find your Security.salt, then go to google type:random strings, click GRC,copy the string to replace it into your file,should look like below:

Configure::write(‘Security.salt’, ‘dVYSYFEl2wYaF5FXSKhFmhGSXBGLmFeyczLUaH4IX8qIKZqo03aasw2jTmcjRP7’);

Third, Debug is optional but I think that it is good have it.

Down load it from cakePHP website name debug_kit-master file put it under your plug file

open bootstrap.php uncommon this statement.

CakePlugin::load(‘DebugKit’); //Loads a single plugin named DebugKit

 

 

then you need create your class

here is the source code for your online stores class

<?php
class OnlineStore
{
    private $DBConnect = null;
    private $storeID = “”;
    private $inventory = array();
    private $shoppingCart = array();
    function __construct()
    {
        include(“inc_OnlineStoreDB.php”);
        $this->DBConnect = $DBConnect;
    }

    
    function __destruct()
    {
        if(!$this->DBConnect->connect_error)
        {
            $this->DBConnect->close();
        }
    }
    
    public function setStoreID($storeID)
    {
        if($this->storeID != $storeID)    
        {
            $this->storeID = $storeID;
            $string = “SELECT * FROM inventory WHERE storeID = ‘”.$this->storeID. “‘”;
            $result = @$this->DBConnect->query($string);
            if(!$result)
            {
                $this->storeID = “”;    
            }
            else
            {
                $this->inventory = array();
                $this->shoppingCart = array();
                while(($row = $result->fetch_assoc())!==null)    
                {
                    $this->inventory[$row[‘productID’]]=array();
                    $this->inventory[$row[‘productID’]][‘name’]=$row[‘name’];
                    $this->inventory[$row[‘productID’]][‘description’]=$row[‘description’];
                    $this->inventory[$row[‘productID’]][‘price’]=$row[‘price’];
                    $this->shoppingCart[$row[‘productID’]]=0;    
                }
            }
                
        }
        
    }
    
    public function getStoreInformation()
    {
        $retval = false;
        if($this->storeID != “”)    
        {
            $string = “SELECT * FROM store_info WHERE storeID = ‘”.$this->storeID . “‘”;
            $result = @$this->DBConnect->query($string);
            if($result)    
            {
                $retval = $result->fetch_assoc();    
            }
        }
        return($retval);
    }
    
    public function getProductList()
    {
        $retval = false;
        $subtotal = 0;
        if(count($this->inventory)>0)
        {
            echo “<table width=\”100%\”>”;
            echo “<tr><th>Product</th><th>Description</th><th>Price each</th><th># in Cart</th><th>Total Price</th><th>&nbsp;</th></tr>”;
            foreach($this->inventory as $ID => $Info)
            {
                echo “<tr><td>”    .htmlentities($Info[‘name’]).”</td>”;
                echo “<td>”.htmlentities($Info[‘description’]).”</td>”;
                printf(“<td class=\”currency\”>$%.2f</td>”,$Info[‘price’]);
                echo “<td class=’currency’>”.$this->shoppingCart[$ID].”</td>”;
                printf(“<td class=’currency’>$%.2f</td>”,$Info[‘price’]*$this->shoppingCart[$ID]);
                echo “<td><a href='”.$_SERVER[‘SCRIPT_NAME’].”?PHPSESSID=”.session_id() .”&ItemToAdd=$ID’>Add Item</a><br/>”;
                echo “<a href='”.$_SERVER[‘SCRIPT_NAME’].”?PHPSESSID=”.session_id() .”&ItemToRemove=$ID’>Remove Item</a></td>”;
                $subtotal += ($Info[‘price’] * $this->shoppingCart[$ID]);                
            }
            
            echo “<tr><td colspan=’4′>Subtotal</td>”;
            printf(“<td class=’currency’>$%.2f</td>”,$subtotal);
            echo “<td><a href='”.$_SERVER[‘SCRIPT_NAME’].”?PHPSESSID=”.session_id() .”&EmptyCart=true’>Empty Cart</a></td></tr>”;
            echo “</table>”;
            
        echo “<p align=’center’><a href=’Checkout.php?PHPSESSID=”.session_id().”&CheckOut=$storeID’>Checkout</a></p>”;    
        }
            
        return($retval);
    }
private function addItem()
{
    $ProdID = $_GET[‘ItemToAdd’];
    if (array_key_exists($ProdID,$this->shoppingCart))
    {
        $this->shoppingCart[$ProdID] += 1;    
    }
        
    
}

function __wakeup()
{
    include(“inc_OnlineStoreDB.php”);
    $this->DBConnect = $DBConnect;    
}

private function removeItem()
{
    $ProdID = $_GET[‘ItemToRemove’];
    if(array_key_exists($ProdID,$this->shoppingCart))
    {
        if($this->shoppingCart[$ProdID]>0)
            {
                $this->shoppingCart[$ProdID]-=1;                
            }
    }
    
}

private function emptyCart()
{
    foreach($this->shoppingCart as $key=>$value)
    {
        $this->shoppingCart[$key]=0;    
    }
    
}

public function processUserInput()
{
    if(!empty($_GET[‘ItemToAdd’]))
    {
        $this->addItem();    
    }
    if(!empty($_GET[‘ItemToRemove’]))
    {
        $this->removeItem();    
    }
    if(!empty($_GET[‘EmptyCart’]))
    {
        $this->emptyCart();    
    }
    
}

public function checkout()
{
        $ProductsOrdered = 0;
        foreach($this->shoppingCart as $productID =>$quantity)
        {
            if ($quantity > 0)
            {
                ++$ProductsOrdered;
                $SQLstring = “INSERT INTO orders ” .” (orderID, productID, quantity) ” .” VALUES(‘” . session_id() . “‘,” .”‘$productID’, $quantity)”;
                $QueryResult = $this->DBConnect->query($SQLstring);
            }
        }
        
        echo “<p><strong>Your order has been ” .”recorded.</strong></p>”;
}
}

?>

Create your databases first

here is your source code for your online shopping cart

— phpMyAdmin SQL Dump
— version 2.10.3
http://www.phpmyadmin.net

— Host: localhost
— Generation Time: Jun 23, 2013 at 10:26 AM
— Server version: 5.0.51
— PHP Version: 5.2.6

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;


— Database: `online_stores`

— ——————————————————–


— Table structure for table `inventory`

CREATE TABLE `inventory` (
  `storeID` varchar(10) default NULL,
  `productID` varchar(10) NOT NULL,
  `name` varchar(100) default NULL,
  `description` varchar(200) default NULL,
  `price` float default NULL,
  PRIMARY KEY  (`productID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


— Dumping data for table `inventory`

INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE001’, ‘Jamaican Blue Mountain Coffee’, ‘This extraordinary coffee, famous for its exquisite flavor and strong body, is grown in teh majestic Blue Mountain range in Jamaica. Weight: 1 pound.’, 22.95);
INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE002’, ‘Blue Grove Hawaiian Maui Premium Coffee’, ‘This delightful coffee has an aroma that is captivatingly rich and nutty with a faint hint of citrus. Weight: 1 pound.’, 18.89);
INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE003’, ‘Sumatra Supreme Coffee’, ‘One of the finest coffees in the world, medium roasted to accentuate its robust character. Weight: 5 pounds.’, 29.95);
INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE004’, ‘Pure Kona Coffee’, ‘Grown and processed using traditional Hawaiian methods, then roasted in small batches to maintain peak freshness and flavor. Weight: 10 ounces.’, 21.45);
INSERT INTO `inventory` VALUES (‘COFFEE’, ‘COFFEE005’, ‘Guatemala Antigua Coffee’, ‘An outstanding coffee with a rich, spicy, and smokey flavor. Weight: 10 ounces.’, 7.5);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE001’, ‘Set of four Shaker ladderback chairs’, ‘From the early 1800”s, this set of four matching ladderback chairs in the traditional Shaker style have been in the same family for eight generations. All four have the original rush seats (one slight’, 12000);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE002’, ‘Hepplewhite Secretary’, ‘All original glass and hardware. Made of mahogany, brass and glass. All decorative inlays and finials intact. Some minor condition issues (bumps and nicks) that add to, rather than detract from, the h’, 19500);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE003’, ‘Empire Sideboard’, ‘Mahogany primary with cypress secondaries. Three drawers above three cupboards. From an ante-bellum Louisiana estate. Excellent condition.’, 3450);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE004’, ‘Gothic Bookcase’, ‘All walnut with blocked corners and glazed sliding doors. This unit has a dentillated pediment and a molded cornice. Wonderful condition, made in New York in the early 1800”s’, 14500);
INSERT INTO `inventory` VALUES (‘ANTIQUE’, ‘ANTIQUE005’, ‘Federal Dining Table’, ‘Mahogany two-pillar dining table. Each urn form column rests on three molded sabre legs with brass paws. Two removable leaves are still in place. Excellent condition, minimal wear.’, 4500);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT001′, ’32GB High Speed microSD card’, ‘With enough speed for high-speed digital cameras and enough storage space for nearly 50 CDs, this card is perfect for your multimedia devices.’, 123.99);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT002’, ‘3-in-1 4GB USB 2.0 Flash Drive Pen and Laser Pointer’, ‘Carry it all in a single device. The bottom is a ball-point pen, the top is a laser pointer, and inside is a 4GB USB flash drive.’, 14.99);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT003’, ‘Bluetooth Bracelet with OLED Display’, ‘Pair this bracelet to your bluetooth-enabled phone, and ringtones are a thing of the past. When a call is received, the bracelet vibrates and the incoming caller ID displays on the OLED screen.’, 49);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT004’, ‘Fitness Watch with Heart Rate Monitor’, ‘Not only does this device time your workout, it monitors your heart rate. Using ANT+ technology, the device can pair with your exercise equipment or an optional foot pod to track your progress. All of’, 149);
INSERT INTO `inventory` VALUES (‘ELECBOUT’, ‘ELECBT005’, ‘Solar Charging Backpack’, ‘Recharge your phone, mp3 player, or handheld device while on the go with this stylish and roomy backpack. The exterior features a solar cell that charges a built-in rechargeable battery. Connectors ar’, 179.95);

— ——————————————————–


— Table structure for table `store_info`

CREATE TABLE `store_info` (
  `storeID` varchar(10) NOT NULL,
  `name` varchar(50) default NULL,
  `description` varchar(200) default NULL,
  `welcome` text,
  `css_file` varchar(250) default NULL,
  `email_address` varchar(100) default NULL,
  PRIMARY KEY  (`storeID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


— Dumping data for table `store_info`

INSERT INTO `store_info` VALUES (‘COFFEE’, ‘Gosselin”s Gourmet Coffee’, ‘Specialty coffees made from the world”s finest beans’, ‘Welcome to Gosselin”s Gourmet Coffee. Here you will find many of the world”s finest gourmet coffees. Our blends are hand-selected from the most unique and flavorful beans, each custom-roasted to enhance the distinct flavor. Whether you desire a dark, medium or light roast, you will find a special treat on our list.’, ‘GosselinGourmet.css’, ‘ggcoffee@example.com’);
INSERT INTO `store_info` VALUES (‘ANTIQUE’, ‘Old Tyme Antiques’, ‘Furniture from America”s Colonial and Post-war periods’, ‘At Old Tyme Antiques, we search for the finest examples of Early American furniture. Our appraisers and researchers have researched each and every one of our items, and all have a certified provenance. Any restoration work has been performed by our expert restorers, and is fully documented. We are constantly searching estate sales for new items. If you have an item, we would be glad to appraise it for you, or even sell it on consignment.’, ‘OldTymeAntiques.css’, ‘antique1783@example.net’);
INSERT INTO `store_info` VALUES (‘ELECBOUT’, ‘Electronic Boutique’, ‘Computer accessories and peripheral devices’, ‘Want the coolest high-tech gadgets around? You”ve come to the right place. We offer USB drives, media cards, and other electronic devices to enhance your digital life.’, ‘ElectronicsBoutique.css’, ‘usb4sale@example.org’);

Use PHP create an program an online order form–continue

Use PHP create  an program an online order form

you could see what it look like,

http://www.sandywebdesigner.com/index.php?section=Final-Project

http://www.sandywebdesigner.com/con_str/stores/GosselinGourmetCoffee.php

http://www.sandywebdesigner.com/con_str/stores/OldTymeAntiques.php

http://www.sandywebdesigner.com/con_str/stores/ElectronicsBoutique.php

the 3 order form just use the same class, you don’t to rewrite it, just change the storeID, you could use for any shopping cart.

the following post i will write the source code.

create a php page with in paypal button and link–this just continue with previous page

<?php
echo “<h1>Welcome to Bazaar online shop</h1>”;
include(“inc_db.php”);//connect to database newsletter
if($DBConnect)
{
$table = “products”;
$query = “select * from $table”;
$result = @mysql_query($query,$DBConnect);
echo “<table width = ‘80%’ border = ‘1’>”;
echo “<tr><th>Name</th><th>Cost</th><th>Image</th><th>Description</th><th>Add to Cart</th><th>Go Pay</th></tr>”;
while($row = mysql_fetch_assoc($result))
{
echo “<tr><td>$row[Name]</td><td>$row[Cost]</td>”;
echo “<td><img src =’images/”.$row[‘Image’].”‘/></td><td>$row[Description]</td><td>”;
echo “<form action=’https://www.paypal.com/cgi-bin/webscr&#8217; method =’post’>”;
echo “<input type=’hidden’ name=’cmd’ value=’_cart’>”;
echo “<input type=’hidden’ name=’business’ value=’youremail@host.com’>”;
echo “<input type=’hidden’ name=’item_name’ value='”.$row[‘Name’].”‘>”;
echo “<input type=’hidden’ name=’amount’ value='”.$row[‘Cost’].”‘>”;
echo “<input type=’hidden’ name=’currency_code’ value=’AUD’>”;
echo “<input type=’hidden’ name=’add’ value=’add’>”;

echo “<input type=’hidden’ name=’bn’ value=’PP-ShopCartBF:btn_cart_LG.gif:NonHostedGuest’>”;
echo “<input type=’image’ src = ‘https://www.paypalobjects.com/en_AU/i/btn/btn_cart_LG.gif&#8217; border=’0′ name=’submit’ alt=’PayPal – The safer,easier way to pay online.’>”;
echo “<img alt=” border=’0′ src=’https://www.paypalobjects.com/en_AU/i/src/pixel.gif&#8217; width=’1′ height=’1′>”;
echo “</form></td>”;
echo “<td><form action=’https://www.paypal.com/cgi-bin/webscr&#8217; method =’post’>”;
echo “<input type=’hidden’ name=’cmd’ value=’_xclick’>”;
echo “<input type=’hidden’ name=’business’ value=’youremail@host.com’>”;
echo “<input type=’hidden’ name=’item_name’ value='”.$row[‘Name’].”‘>”;
echo “<input type=’hidden’ name=’amount’ value='”.$row[‘Cost’].”‘>”;
echo “<input type=’hidden’ name=’currency_code’ value=’AUD’>”;
echo “<input type=’hidden’ name=’bn’ value=’PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest’>”;
echo “<input type=’image’ src = ‘https://www.paypalobjects.com/en_AU/i/btn/btn_buynowCC_LG.gif&#8217; border=’0′ name=’submit’ alt=’PayPal – The safer,easier way to pay online.’>”;
echo “<img alt=” border=’0′ src=’https://www.paypalobjects.com/en_Au/i/src/pixel.gif&#8217; width=’1′ height=’1′>”;
echo “</form></td></tr>”;

}
echo “</table>”;
mysql_free_result($result);
mysql_close($DBConnect);

}
?>