Showing posts with label Mysql. Show all posts
Showing posts with label Mysql. Show all posts

Mysql Fourth Maximum Salary And 5th Maximum Salary

Mysql Fourth Maximum Salary AND 5th Maximum Salary 

Hi Today Discussed Mysql Fourth Maximum Salary and 5th Maximum Salary How to Get Select Query is just a easy way select query and then count max salary follows query.

Mysql Four Maximum Salary And 5th Maximum Salary
Mysql Four Maximum Salary And 5th Maximum Salary 
Second Maximum Salary

SELECT 
    name, Salary
FROM
    emp a
WHERE
    1 = (SELECT 
            COUNT(name)
        FROM
            emp b
        WHERE
            b.Salary> a.Salary);
Third Maximum Salary

SELECT 
    name, Salary
FROM
    emp a
WHERE
    2 = (SELECT 
            COUNT(name)
        FROM
            emp b
        WHERE
            b.Salary> a.Salary);
Fourth Maximum Salary

SELECT 
    name, Salary
FROM
    emp a
WHERE
    3 = (SELECT 
            COUNT(name)
        FROM
            emp b
        WHERE
            b.Salary> a.Salary);
5th Maximum Salary
SELECT 
    name, Salary
FROM
    emp a
WHERE
    4 = (SELECT 
            COUNT(name)
        FROM
            emp b
        WHERE
            b.Salary> a.Salary);

Country And Currency Database

Currency Database

Hi Today discussed Country And Currency Database mysql database basic database country currency symbol and separator database followus code.

Country And Currency Database
Country And Currency Database


CREATE TABLE IF NOT EXISTS `currencies` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `country` varchar(100) DEFAULT NULL,
  `currency` varchar(100) DEFAULT NULL,
  `code` varchar(25) DEFAULT NULL,
  `symbol` varchar(25) DEFAULT NULL,
  `thousand_separator` varchar(10) DEFAULT NULL,
  `decimal_separator` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=132 DEFAULT CHARSET=utf8;

-- Dumping data for table invoice_new.currencies: 131 rows
/*!40000 ALTER TABLE `currencies` DISABLE KEYS */;
INSERT INTO `currencies` (`id`, `country`, `currency`, `code`, `symbol`, 
`thousand_separator`, `decimal_separator`) VALUES
 (1, 'Albania', 'Leke', 'ALL', 'Lek', ',', '.'),
 (2, 'America', 'Dollars', 'USD', '$', ',', '.'),
 (3, 'Afghanistan', 'Afghanis', 'AF', '؋', ',', '.'),
 (4, 'Argentina', 'Pesos', 'ARS', '$', ',', '.'),
 (5, 'Aruba', 'Guilders', 'AWG', 'ƒ', ',', '.'),
 (6, 'Australia', 'Dollars', 'AUD', '$', ',', '.'),
 (7, 'Azerbaijan', 'New Manats', 'AZ', 'ман', ',', '.'),
 (8, 'Bahamas', 'Dollars', 'BSD', '$', ',', '.'),
 (9, 'Barbados', 'Dollars', 'BBD', '$', ',', '.'),
 (10, 'Belarus', 'Rubles', 'BYR', 'p.', ',', '.'),
 (11, 'Belgium', 'Euro', 'EUR', '€', ',', '.'),
 (12, 'Beliz', 'Dollars', 'BZD', 'BZ$', ',', '.'),
 (13, 'Bermuda', 'Dollars', 'BMD', '$', ',', '.'),
 (14, 'Bolivia', 'Bolivianos', 'BOB', '$b', ',', '.'),
 (15, 'Bosnia and Herzegovina', 'Convertible Marka', 'BAM', 'KM', ',', '.'),
 (16, 'Botswana', 'Pula\'s', 'BWP', 'P', ',', '.'),
 (17, 'Bulgaria', 'Leva', 'BG', 'лв', ',', '.'),
 (18, 'Brazil', 'Reais', 'BRL', 'R$', ',', '.'),
 (19, 'Britain (United Kingdom)', 'Pounds', 'GBP', '£', ',', '.'),
 (20, 'Brunei Darussalam', 'Dollars', 'BND', '$', ',', '.'),
 (21, 'Cambodia', 'Riels', 'KHR', '៛', ',', '.'),
 (22, 'Canada', 'Dollars', 'CAD', '$', ',', '.'),
 (23, 'Cayman Islands', 'Dollars', 'KYD', '$', ',', '.'),
 (24, 'Chile', 'Pesos', 'CLP', '$', ',', '.'),
 (25, 'China', 'Yuan Renminbi', 'CNY', '¥', ',', '.'),
 (26, 'Colombia', 'Pesos', 'COP', '$', ',', '.'),
 (27, 'Costa Rica', 'Colón', 'CRC', '₡', ',', '.'),
 (28, 'Croatia', 'Kuna', 'HRK', 'kn', ',', '.'),
 (29, 'Cuba', 'Pesos', 'CUP', '₱', ',', '.'),
 (30, 'Cyprus', 'Euro', 'EUR', '€', ',', '.'),
 (31, 'Czech Republic', 'Koruny', 'CZK', 'Kč', ',', '.'),
 (32, 'Denmark', 'Kroner', 'DKK', 'kr', ',', '.'),
 (33, 'Dominican Republic', 'Pesos', 'DOP ', 'RD$', ',', '.'),
 (34, 'East Caribbean', 'Dollars', 'XCD', '$', ',', '.'),
 (35, 'Egypt', 'Pounds', 'EGP', '£', ',', '.'),
 (36, 'El Salvador', 'Colones', 'SVC', '$', ',', '.'),
 (37, 'England (United Kingdom)', 'Pounds', 'GBP', '£', ',', '.'),
 (38, 'Euro', 'Euro', 'EUR', '€', ',', '.'),
 (39, 'Falkland Islands', 'Pounds', 'FKP', '£', ',', '.'),
 (40, 'Fiji', 'Dollars', 'FJD', '$', ',', '.'),
 (41, 'France', 'Euro', 'EUR', '€', ',', '.'),
 (42, 'Ghana', 'Cedis', 'GHC', '¢', ',', '.'),
 (43, 'Gibraltar', 'Pounds', 'GIP', '£', ',', '.'),
 (44, 'Greece', 'Euro', 'EUR', '€', ',', '.'),
 (45, 'Guatemala', 'Quetzales', 'GTQ', 'Q', ',', '.'),
 (46, 'Guernsey', 'Pounds', 'GGP', '£', ',', '.'),
 (47, 'Guyana', 'Dollars', 'GYD', '$', ',', '.'),
 (48, 'Holland (Netherlands)', 'Euro', 'EUR', '€', ',', '.'),
 (49, 'Honduras', 'Lempiras', 'HNL', 'L', ',', '.'),
 (50, 'Hong Kong', 'Dollars', 'HKD', '$', ',', '.'),
 (51, 'Hungary', 'Forint', 'HUF', 'Ft', ',', '.'),
 (52, 'Iceland', 'Kronur', 'ISK', 'kr', ',', '.'),
 (53, 'India', 'Rupees', 'INR', 'Rp', ',', '.'),
 (54, 'Indonesia', 'Rupiahs', 'IDR', 'Rp', ',', '.'),
 (55, 'Iran', 'Rials', 'IRR', '﷼', ',', '.'),
 (56, 'Ireland', 'Euro', 'EUR', '€', ',', '.'),
 (57, 'Isle of Man', 'Pounds', 'IMP', '£', ',', '.'),
 (58, 'Israel', 'New Shekels', 'ILS', '₪', ',', '.'),
 (59, 'Italy', 'Euro', 'EUR', '€', ',', '.'),
 (60, 'Jamaica', 'Dollars', 'JMD', 'J$', ',', '.'),
 (61, 'Japan', 'Yen', 'JPY', '¥', ',', '.'),
 (62, 'Jersey', 'Pounds', 'JEP', '£', ',', '.'),
 (63, 'Kazakhstan', 'Tenge', 'KZT', 'лв', ',', '.'),
 (64, 'Korea (North)', 'Won', 'KPW', '₩', ',', '.'),
 (65, 'Korea (South)', 'Won', 'KRW', '₩', ',', '.'),
 (66, 'Kyrgyzstan', 'Soms', 'KGS', 'лв', ',', '.'),
 (67, 'Laos', 'Kips', 'LAK', '₭', ',', '.'),
 (68, 'Latvia', 'Lati', 'LVL', 'Ls', ',', '.'),
 (69, 'Lebanon', 'Pounds', 'LBP', '£', ',', '.'),
 (70, 'Liberia', 'Dollars', 'LRD', '$', ',', '.'),
 (71, 'Liechtenstein', 'Switzerland Francs', 'CHF', 'CHF', ',', '.'),
 (72, 'Lithuania', 'Litai', 'LTL', 'Lt', ',', '.'),
 (73, 'Luxembourg', 'Euro', 'EUR', '€', ',', '.'),
 (74, 'Macedonia', 'Denars', 'MKD', 'ден', ',', '.'),
 (75, 'Malaysia', 'Ringgits', 'MYR', 'RM', ',', '.'),
 (76, 'Malta', 'Euro', 'EUR', '€', ',', '.'),
 (77, 'Mauritius', 'Rupees', 'MUR', '₨', ',', '.'),
 (78, 'Mexico', 'Pesos', 'MX', '$', ',', '.'),
 (79, 'Mongolia', 'Tugriks', 'MNT', '₮', ',', '.'),
 (80, 'Mozambique', 'Meticais', 'MZ', 'MT', ',', '.'),
 (81, 'Namibia', 'Dollars', 'NAD', '$', ',', '.'),
 (82, 'Nepal', 'Rupees', 'NPR', '₨', ',', '.'),
 (83, 'Netherlands Antilles', 'Guilders', 'ANG', 'ƒ', ',', '.'),
 (84, 'Netherlands', 'Euro', 'EUR', '€', ',', '.'),
 (85, 'New Zealand', 'Dollars', 'NZD', '$', ',', '.'),
 (86, 'Nicaragua', 'Cordobas', 'NIO', 'C$', ',', '.'),
 (87, 'Nigeria', 'Nairas', 'NG', '₦', ',', '.'),
 (88, 'North Korea', 'Won', 'KPW', '₩', ',', '.'),
 (89, 'Norway', 'Krone', 'NOK', 'kr', ',', '.'),
 (90, 'Oman', 'Rials', 'OMR', '﷼', ',', '.'),
 (91, 'Pakistan', 'Rupees', 'PKR', '₨', ',', '.'),
 (92, 'Panama', 'Balboa', 'PAB', 'B/.', ',', '.'),
 (93, 'Paraguay', 'Guarani', 'PYG', 'Gs', ',', '.'),
 (94, 'Peru', 'Nuevos Soles', 'PE', 'S/.', ',', '.'),
 (95, 'Philippines', 'Pesos', 'PHP', 'Php', ',', '.'),
 (96, 'Poland', 'Zlotych', 'PL', 'zł', ',', '.'),
 (97, 'Qatar', 'Rials', 'QAR', '﷼', ',', '.'),
 (98, 'Romania', 'New Lei', 'RO', 'lei', ',', '.'),
 (99, 'Russia', 'Rubles', 'RUB', 'руб', ',', '.'),
 (100, 'Saint Helena', 'Pounds', 'SHP', '£', ',', '.'),
 (101, 'Saudi Arabia', 'Riyals', 'SAR', '﷼', ',', '.'),
 (102, 'Serbia', 'Dinars', 'RSD', 'Дин.', ',', '.'),
 (103, 'Seychelles', 'Rupees', 'SCR', '₨', ',', '.'),
 (104, 'Singapore', 'Dollars', 'SGD', '$', ',', '.'),
 (105, 'Slovenia', 'Euro', 'EUR', '€', ',', '.'),
 (106, 'Solomon Islands', 'Dollars', 'SBD', '$', ',', '.'),
 (107, 'Somalia', 'Shillings', 'SOS', 'S', ',', '.'),
 (108, 'South Africa', 'Rand', 'ZAR', 'R', ',', '.'),
 (109, 'South Korea', 'Won', 'KRW', '₩', ',', '.'),
 (110, 'Spain', 'Euro', 'EUR', '€', ',', '.'),
 (111, 'Sri Lanka', 'Rupees', 'LKR', '₨', ',', '.'),
 (112, 'Sweden', 'Kronor', 'SEK', 'kr', ',', '.'),
 (113, 'Switzerland', 'Francs', 'CHF', 'CHF', ',', '.'),
 (114, 'Suriname', 'Dollars', 'SRD', '$', ',', '.'),
 (115, 'Syria', 'Pounds', 'SYP', '£', ',', '.'),
 (116, 'Taiwan', 'New Dollars', 'TWD', 'NT$', ',', '.'),
 (117, 'Thailand', 'Baht', 'THB', '฿', ',', '.'),
 (118, 'Trinidad and Tobago', 'Dollars', 'TTD', 'TT$', ',', '.'),
 (119, 'Turkey', 'Lira', 'TRY', 'TL', ',', '.'),
 (120, 'Turkey', 'Liras', 'TRL', '£', ',', '.'),
 (121, 'Tuvalu', 'Dollars', 'TVD', '$', ',', '.'),
 (122, 'Ukraine', 'Hryvnia', 'UAH', '₴', ',', '.'),
 (123, 'United Kingdom', 'Pounds', 'GBP', '£', ',', '.'),
 (124, 'United States of America', 'Dollars', 'USD', '$', ',', '.'),
 (125, 'Uruguay', 'Pesos', 'UYU', '$U', ',', '.'),
 (126, 'Uzbekistan', 'Sums', 'UZS', 'лв', ',', '.'),
 (127, 'Vatican City', 'Euro', 'EUR', '€', ',', '.'),
 (128, 'Venezuela', 'Bolivares Fuertes', 'VEF', 'Bs', ',', '.'),
 (129, 'Vietnam', 'Dong', 'VND', '₫', ',', '.'),
 (130, 'Yemen', 'Rials', 'YER', '﷼', ',', '.'),
 (131, 'Zimbabwe', 'Zimbabwe Dollars', 'ZWD', 'Z$', ',', '.');

Paypal Integration With PHP & MYSQL

PAYPAL INTEGRATION WITH PHP & MYSQL


Paypal Integration
Paypal Integration
Previously Discussed Simple PHP shopping cart stored a cart payment integration is discussed Follow us
Simple Way to PHP Paypal Integration following steps.

Step : 1

First Setup your Paypal Account

Signup Paypal Account if you don't already have one.  In order to use PIN, the paypal account you are selling from must be a Business Account

Select ‘edit profile’ from your PayPal account and check the following settings.

Under ‘My Selling Preferences’ >> ‘Getting paid and managing risk’ >> ‘Instant Payment Notification Preferences’
  1. Set the IPN value to ‘On’
  2. Set the IPN URL to the PHP page containing the IPN code shown in steps 3 & 4 of this tutorial. (http://www.example.com/payment.php)
Step : 2

Your Website Looking UI design and must now send all required value to paypal so that the payment can be processed.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Paypal Integration Test</title>
</head>
<body>
<form class="paypal" action="payments.php" method="post" id="paypal_form" target="_blank">
<input type="hidden" name="command" value="_xclick" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="lc" value="UK" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
<input type="hidden" name="first_name" value="Customer's First Name" />
<input type="hidden" name="last_name" value="Customer's Last Name" />
<input type="hidden" name="payer_email" value="customer@example.com" />
<input type="hidden" name="item_number" value="123456" / >
<input type="submit" name="submit" value="Submit Payment"/>
</form>
</body>
</html>

Step:3 

Paymen Page REQUEST 

// Database variables
$hostname = "localhost"; //database location
$username = ""; //database username
$password = ""; //database password
$db_name = ""; //database name
// PayPal settings
$paypal_email = 'user@domain.com';
$return_url = 'http://domain.com/payment-successful.html';
$cancel_url = 'http://domain.com/payment-cancelled.html';
$notify_url = 'http://domain.com/payments.php';
$item_name = 'Test Item';
$item_amount = 5.00;
// Include Functions
include("functions.php");
// Check if paypal request or response
if (!isset($_POST["txn_id"]) &amp;amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp;amp; !isset($_POST["txn_type"])){
    $querystring = '';
    // Firstly Append paypal account to querystring
    $querystring .= "?business=".urlencode($paypal_email)."&amp;amp;amp;amp;amp;amp;";
    // Append amount&amp;amp;amp;amp;amp;amp; currency (£) to quersytring so it cannot be edited in html
    //The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable.
    $querystring .= "item_name=".urlencode($item_name)."&amp;amp;amp;amp;amp;amp;";
    $querystring .= "amount=".urlencode($item_amount)."&amp;amp;amp;amp;amp;amp;";
    //loop for posted values and append to querystring
    foreach($_POST as $key =&amp;amp;amp;amp;amp;gt; $value) {
        $value = urlencode(stripslashes($value));
        $querystring .= "$key=$value&amp;amp;amp;amp;amp;amp;";
    }
    // Append paypal return addresses
    $querystring .= "return=".urlencode(stripslashes($return_url))."&amp;amp;amp;amp;amp;amp;";
    $querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&amp;amp;amp;amp;amp;amp;";
    $querystring .= "notify_url=".urlencode($notify_url);
    // Append querystring with custom field
    //$querystring .= "&amp;amp;amp;amp;amp;amp;custom=".USERID;
    // Redirect to paypal IPN
    header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring);
    exit();
} else {
   // Response from PayPal
}
Step: 4 

Payment Page Response

 // Database variables
$hostname = "localhost"; //database location
$username = ""; //database username
$password = ""; //database password
$db_name = ""; //database name

// PayPal settings
$paypal_email = 'user@domain.com';
$return_url = 'http://domain.com/payment-successful.html';
$cancel_url = 'http://domain.com/payment-cancelled.html';
$notify_url = 'http://domain.com/payments.php';

$item_name = 'Test Item';
$item_amount = 5.00;

// Include Functions
include("functions.php");

// Check if paypal request or response
if (!isset($_POST["txn_id"]) &amp;amp;amp;&amp;amp;amp; !isset($_POST["txn_type"])){
    $querystring = '';
    
    // Firstly Append paypal account to querystring
    $querystring .= "?business=".urlencode($paypal_email)."&amp;amp;amp;";
    
    // Append amount&amp;amp;amp; currency (£) to quersytring so it cannot be edited in html
    
    //The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable.
    $querystring .= "item_name=".urlencode($item_name)."&amp;amp;amp;";
    $querystring .= "amount=".urlencode($item_amount)."&amp;amp;amp;";
    
    //loop for posted values and append to querystring
    foreach($_POST as $key =&amp;amp;gt; $value){
        $value = urlencode(stripslashes($value));
        $querystring .= "$key=$value&amp;amp;amp;";
    }
    
    // Append paypal return addresses
    $querystring .= "return=".urlencode(stripslashes($return_url))."&amp;amp;amp;";
    $querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&amp;amp;amp;";
    $querystring .= "notify_url=".urlencode($notify_url);
    
    // Append querystring with custom field
    //$querystring .= "&amp;amp;amp;custom=".USERID;
    
    // Redirect to paypal IPN
    header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring);
    exit();
} else {
    //Database Connection
    $link = mysql_connect($host, $user, $pass);
    mysql_select_db($db_name);
    
    // Response from Paypal

    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';
    foreach ($_POST as $key =&amp;amp;gt; $value) {
        $value = urlencode(stripslashes($value));
        $value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
        $req .= "&amp;amp;amp;$key=$value";
    }
    
    // assign posted variables to local variables
    $data['item_name']          = $_POST['item_name'];
    $data['item_number']        = $_POST['item_number'];
    $data['payment_status']     = $_POST['payment_status'];
    $data['payment_amount']     = $_POST['mc_gross'];
    $data['payment_currency']   = $_POST['mc_currency'];
    $data['txn_id']             = $_POST['txn_id'];
    $data['receiver_email']     = $_POST['receiver_email'];
    $data['payer_email']        = $_POST['payer_email'];
    $data['custom']             = $_POST['custom'];
        
    // post back to PayPal system to validate
    $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
    $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
    
    $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
    
    if (!$fp) {
        // HTTP ERROR
        
    } else {
        fputs($fp, $header . $req);
        while (!feof($fp)) {
            $res = fgets ($fp, 1024);
            if (strcmp($res, "VERIFIED") == 0) {
                
                // Used for debugging
                // mail('user@domain.com', 'PAYPAL POST - VERIFIED RESPONSE', print_r($post, true));
                        
                // Validate payment (Check unique txnid &amp;amp;amp; correct price)
                $valid_txnid = check_txnid($data['txn_id']);
                $valid_price = check_price($data['payment_amount'], $data['item_number']);
                // PAYMENT VALIDATED &amp;amp;amp; VERIFIED!
                if ($valid_txnid &amp;amp;amp;&amp;amp;amp; $valid_price) {
                    
                    $orderid = updatePayments($data);
                    
                    if ($orderid) {
                        // Payment has been made &amp;amp;amp; successfully inserted into the Database
                    } else {
                        // Error inserting into DB
                        // E-mail admin or alert user
                        // mail('user@domain.com', 'PAYPAL POST - INSERT INTO DB WENT WRONG', print_r($data, true));
                    }
                } else {
                    // Payment made but data has been changed
                    // E-mail admin or alert user
                }
            
            } else if (strcmp ($res, "INVALID") == 0) {
            
                // PAYMENT INVALID &amp;amp;amp; INVESTIGATE MANUALY!
                // E-mail admin or alert user
                
                // Used for debugging
                //@mail("user@domain.com", "PAYPAL DEBUGGING", "Invalid Response
data =
&amp;amp;lt;pre&amp;amp;gt;".print_r($post, true)."&amp;amp;lt;/pre&amp;amp;gt;

");
            }
        }
    fclose ($fp);
    }
}


Step 5 - Function.php


// functions.php
function check_txnid($tnxid){
global $link;
return true;
$valid_txnid = true;
//get result set
$sql = mysql_query("SELECT * FROM `payments` WHERE txnid = '$tnxid'", $link);
if ($row = mysql_fetch_array($sql)) {
$valid_txnid = false;
}
return $valid_txnid;
}

function check_price($price, $id){
$valid_price = false;
//you could use the below to check whether the correct price has been paid for the product

/*
$sql = mysql_query("SELECT amount FROM `products` WHERE id = '$id'");
if (mysql_num_rows($sql) != 0) {
while ($row = mysql_fetch_array($sql)) {
$num = (float)$row['amount'];
if($num == $price){
$valid_price = true;
}
}
}
return $valid_price;
*/
return true;
}

function updatePayments($data){
global $link;

if (is_array($data)) {
$sql = mysql_query("INSERT INTO `payments` (txnid, payment_amount, payment_status, itemid, createdtime) VALUES (
'".$data['txn_id']."' ,
'".$data['payment_amount']."' ,
'".$data['payment_status']."' ,
'".$data['item_number']."' ,
'".date("Y-m-d H:i:s")."'
)", $link);
return mysql_insert_id($link);
}
}


Step: 6 Databast Table

Website Paypal Integration store payment details inset database table is most Important.

CREATE TABLE IF NOT EXISTS `payments` (
 `id` int(6) NOT NULL AUTO_INCREMENT,
 `txnid` varchar(20) NOT NULL,
 `payment_amount` decimal(7,2) NOT NULL,
 `payment_status` varchar(25) NOT NULL,
 `itemid` varchar(25) NOT NULL,
 `createdtime` datetime NOT NULL,
 PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;







mysql queries



msql

db Connect:

<?php
$dbhost = 'localhost';
$dbusername = 'root';
$dbpassword = 'dev2tricks';
$conn = mysql_connect($dbhost,$dbusername,$dbpassword);
if($conn!=""){
die('could not connect: '.mysql_error()); }
else{
echo 'db Connect Successfully';
}
 ?>

The SQL Query SELECT command is used to fetch data from mysql database table.  You can use this command at mysql syntax sample code prompt as well as in any script like php.

SELECT Query Syntax:


SELECT * FROM `table_name`;
or
 SELECT field1, field2, table-name1, table-name2 ... [WHERE Clause]  [LIMIT N]


Example code:

$sql = 'SELECT * FROM `table_name`';
mysql_select_db('db_name');
$con = mysql_query($sql, $conn);
while($datas = mysql_fetch_array($con))
{
echo "$datas['field-name']";
}


Table Field Name Rename:

It is important to remember that the table hasn't actually been renamed, but instead the new_table_name.

SELECT `fieldname` As 'new name' from `tablename`;


More MYSQLJOINQUERY