Friday, December 17, 2010

Prob in IE and chrome of div is displaying behind flash image on mouse hover

In some case if you mouse over in menu and it will display or show sub menu some time that sub menu will display behind flash image so add below code(<param name="wmode" value="transparent">) in side object tag


<object style="vertical-align: bottom;z-index:-999;" width="689" height="324" data="">getSkinUrl('');?>images/homePage/banner2.swf" type="application/x-shockwave-flash">

<param name="wmode" value="transparent"><embed src=""></embed>getSkinUrl('');?>images/homePage/banner2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="689" height="324" wmode="transparent">

</object>

Tuesday, November 16, 2010

nu soap with joomla

Place this code in one file modify as per your requirement and add nu soap library
i palace this file inside one folder called sopa inside root folder of joomla project and also i use model from component in this i placed my model in side com-community folder and i call one model and in this example i added multiple in put , compex type out put with array variable, and u can see out put in soap UI




require_once("nusoap/nusoap.php"); //nusopa.php download from net and include it
$ns = "http://soaptest/";

if(!defined('_JEXEC'))
define( '_JEXEC', 1 );
set_time_limit(0);
ini_set('include_path', '../');
if(!defined('JPATH_BASE'))
define('JPATH_BASE', ini_get('include_path') );
if(!defined('DS'))
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
//require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'database'.DS.'table'.DS.'table.php' );


if(!isset($mainframe))
$mainframe =& JFactory::getApplication('site');

//jimport( 'joomla.plugin.plugin' );
//jimport('joomla.filesystem.file');
require_once( JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'plugin' . DS . 'helper.php');

require_once( JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php');


require_once("convertingArrayinput.php");

function GetEventInfo(&$EventId,&$Version) {
jimport( 'joomla.application.component.model' );
JModel::addIncludePath(JPATH_ROOT.DS.'components'.DS.'com_community'.DS.'models');
$profilemodel =& JModel::getInstance('webprofile', 'CommunityModel');

//$user =& JFactory::getUser($userid);
//$VersionReq=$user->Version;
//$role=$user->Role;
if($EventId) {
$result = array();
$teams= array();
$clubdata=$profilemodel->getEventInfo($EventId,$Version);
$teamdata=$profilemodel->getEventTeams($EventId);
//print_r($clubdata);
foreach($teamdata as $team) {
$teams[]=array('TeamId'=>$team->TeamId,'TeamName'=>$team->TeamName);
}
foreach($clubdata as $row) {
$result1= array('UserData'=>array('UserId'=>$row->UserId,'Role'=>$row->Role),
'EventData'=>array('EventDetails'=>array('EventId'=>$row->EventId,'EventName'=>$row->EventName,'EventLocation'=>$row->FacilityName,'EventLogo'=>$row->EventLogoPath,'EventDate'=>$row->Event),
'Facility'=>array('Longtitude'=>$row->FacilityLongtitude,'Latitude'=>$row->FacliltyLatitude),
'Schedule'=>$row->ScheduleLink,'Rules'=>$row->RulesLink,'WeatherLine'=>$row->WeatherLine,
'Teams'=>$teams));
}

$res = array('Response' => array('Code' => '100','Msg'=>'Successful'),
'ResponseData'=>$result1);
return $res;
} else {

$res = array('Response' => array('Code' => '-100','Msg'=>'In Valid Event Id'),
'ResponseData'=> array());

}



}


function checkDate1($date1){
return preg_match('`^(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$`', $date1) ? TRUE : FALSE;
}

$server = new soap_server();
$server->configureWSDL('GetEventInfo', $ns);
$server->wsdl->schemaTargetNamespace = $ns;
$server->debug_flag = true;

$server->wsdl->addComplexType(
'ResponseInfo',
'complexType',
'struct',
'all',
'',
array(
'Response' => array('name' => 'Response', 'type' => 'tns:Response'),
'ResponseData' => array('name' => 'ResponseData', 'type' => 'tns:ResponseData'),
)
);

$server->wsdl->addComplexType(
'Response',
'complexType',
'struct',
'all',
'',
array(
'Code' => array('name' => 'Code', 'type' => 'xsd:int'),
'Msg' => array('name' => 'Msg', 'type' => 'xsd:string')
)
);


$server->wsdl->addComplexType(
'TeamsArray',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:Team[]')
),
'tns:Team'
);




$server->wsdl->addComplexType(
'Team',
'element',
'struct',
'all',
'',
array(
'TeamId' => array('name' => 'TeamId', 'type' => 'xsd:int'),
'TeamName' => array('name' => 'TeamName', 'type' => 'xsd:string')
)
);


$server->wsdl->addComplexType(
'UserData',
'complexType',
'struct',
'all',
'',
array(
'UserId' => array('name' => 'UserId', 'type' => 'xsd:int'),
'Role' => array('name' => 'Role', 'type' => 'xsd:string')
)
);

$server->wsdl->addComplexType(
'EventDetails',
'complexType',
'struct',
'all',
'',
array(
'EventId' => array('name' => 'EventId', 'type' => 'xsd:int'),
'EventName' => array('name' => 'EventName', 'type' => 'xsd:string'),
'EventLocation' => array('name' => 'EventLocation', 'type' => 'xsd:string'),
'EventLogoPath' => array('name' => 'EventLogoPath', 'type' => 'xsd:string'),
'EventDate' => array('name' => 'EventDate', 'type' => 'xsd:date')
)
);

$server->wsdl->addComplexType(
'Facility',
'complexType',
'struct',
'all',
'',
array(
'Longtitude' => array('name' => 'Longtitude', 'type' => 'xsd:string'),
'Latitude' => array('name' => 'Latitude', 'type' => 'xsd:string')
)
);


$server->wsdl->addComplexType(
'EventData',
'complexType',
'struct',
'all',
'',
array(
'EventDetails' => array('name' => 'EventDetails', 'type' => 'tns:EventDetails'),
'Facility' => array('name' => 'Facility', 'type' => 'tns:Facility'),
'Schedule' => array('name' => 'Schedule', 'type' => 'xsd:string'),
'Rules' => array('name' => 'Rules', 'type' => 'xsd:string'),
'WeatherLine' => array('name' => 'WeatherLine', 'type' => 'xsd:string'),
'Teams' => array('name' => 'Teams', 'type' => 'tns:TeamsArray')
)
);

$server->wsdl->addComplexType(
'ResponseData',
'complexType',
'struct',
'all',
'',
array(
'UserData' => array('name' => 'UserData', 'type' => 'tns:UserData'),
'EventData' => array('name' => 'EventData', 'type' => 'tns:EventData')
)
);


$inparams = array('EventId' => 'xsd:int', 'Version' => 'xsd:string');
//$outparams = array('msg' => 'xsd:string','name' => 'xsd:string','role'=> 'xsd:int','email'=> 'xsd:string','lastName'=> 'xsd:string','temp'=>'xsd:array');
//$outparams = array('name'=> 'xsd:string', 'emailArray' => 'tns:ContactArray');
$outparams = $outparams = array('ResponseInfo' => 'tns:ResponseInfo');

//$outparams = $outparams = array('ResponseInfo' => 'xsd:string');
//$outparams = array('ProfileInfo'=> 'tns:Book');
$server->register('GetEventInfo', $inparams, $outparams, $ns, false);

if (!isset($HTTP_RAW_POST_DATA))
$HTTP_RAW_POST_DATA = file_get_contents("php://input");

$server->service($HTTP_RAW_POST_DATA);
file_put_contents("sqlwsdl.log", $HTTP_RAW_POST_DATA."\r\n".$server->getDebug());
?>

Tuesday, July 6, 2010

Package Trip from bangalore to tirupati

Hi
I like to share the information about my package trip to Tirupati in Green-line travels

Its awesome trip

* They pick us near indranagar depo
* They collected our ticket and give one boarding ticket keep safe its very important
* Once u seated they will give half liter water,and some Snacks
* Its Volvo bus so seats are comfort
* Around 8:30 pm bus will leave banglore
* Around 11:30 bus will stop for 15 min in some hotel
* Around 2 O'clock it will reach to Tirupati
* They will give room's to fresh up .. room was good... only 45min or 1 hour time to fresh up
* Around 3 one TDT bus is ready to take u to Tirumala
* It took 1 hour to reach to Tirumala
* Phone and Camera's are not allowed so your guide will tell to keep things and sleepers in one shop...... its safe no problem if u keep there... per mobile he will charge 10Rs took keep..
* Guide will give 300Rs to every one to take sigarra darsann ticket .. and will be in Q for Darsanna
* If rush is less then u will come out with in 7 :30
* Else it will 9:30 each 300Rs ticket u will get 2 Laddu. once u came out from temple. u will get break fast which is included in package.
* 10 O'clock u will Tirumala and come back to Tirupati.. u will back to volvo bus and You will moved to one more temple Padmavati Devi Temple Wife of Tirupati
* 12:30 Lunch this is also include in package
* 7:30 will be back to Banglore


Cost of Ticket per head is 1450Rs which include 1beakfast,1lunch, sigarra Darsanna ticket and Volvo bus


I hope this package is very good

Monday, June 28, 2010

Creating a table in for loop each row with 5 column

If Your retrieving a n-number of data from database and wants to display in table like with n*m row*col then this code will be used
$col is number of column's

O/P will be like this




<table border="1px"> ?php $col=5; for ( $i=1; $i<=20; $i++){ if(!($i-1 % $col)){ ?> <tr><?php } ?> <td><?php echo $i; ?></td> <?php if(!($i % $col)){?> </tr> <?php }
} ?> </table>

Monday, May 17, 2010

Renaming id name in javascript

old is old id where we are going to rename it to new

function renameID()
{
document.getElementById("old").id = "new";
}

onclick="renameID()"

Wednesday, May 5, 2010

Adding and removing text box Which also insert a row next or Beneath the row

In this program We can add the row and we can also insert the row beneath the row
and we can remove the row.... dynamic select box value from database.. can be added each time to row

this program is calculating tax i did in html u can make it use in php by give the tax value from data base presently its static value

Remove all opening and closed BR tags and then run
ADD THIS IN HEAD TAG



<SCRIPT language="javascript">


function insRow1(id)
{
var m = document.getElementById(id).rowIndex;
++m;
var x=document.getElementById('myTable').insertRow(m);
id = ++id;
var y=x.insertCell(0);
var z=x.insertCell(1);
var g=x.insertCell(2);
var w=x.insertCell(3);
var h=x.insertCell(4);
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
--rowCount;
var divIdName = 'my'+rowCount+'Div';
x.setAttribute('id',divIdName);
var rowCount1=--rowCount;
y.innerHTML="<input type='text' value='' onkeyup=total2() id="+divIdName+"FT>";
z.innerHTML="<input type='text' value='' onkeyup=total2() id="+divIdName+"ST>";
g.innerHTML =table.rows[1].cells[2].innerHTML;
w.innerHTML="<input type='button' id="+divIdName+"Add onclick=insRow1('"+divIdName+"') value='Insert row'>";
h.innerHTML="<input type='button' id="+divIdName+"Del onclick=deleteRow('"+divIdName+"') value='Delete'>";
g.firstChild.setAttribute('id',divIdName+'Sel');
g.firstChild.setAttribute('onchange','total2()');
}


function deleteRow(tableID) {
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
var m = document.getElementById(tableID).rowIndex;
table.deleteRow(m);
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
var v=0;
for(var m=1;m<rowCount;m++) {
var Ft=document.getElementById(table.rows[m].cells[0].firstChild.getAttribute('id')).value;
var St=document.getElementById(table.rows[m].cells[1].firstChild.getAttribute('id')).value;
var Sel=document.getElementById(table.rows[m].cells[2].firstChild.getAttribute('id')).value
if(!Ft) {
Ft=0;
}
if(!St) {
St=0;
}

var to= parseInt(St) * parseInt(Ft);
if(!Sel) {
var tax=0;
} else {
var tax=to*(Sel/100);
}
to=parseInt(to)+parseFloat(tax);
if(Ft && St) {
v=parseFloat(v)+parseFloat(to);
}
}
document.getElementById('total1').value=v;
}

function total2() {
var table = document.getElementById('myTable');
var rowCount = table.rows.length;
var v=0;
for(var m=1;m<rowCount;m++) {
var Ft=document.getElementById(table.rows[m].cells[0].firstChild.getAttribute('id')).value;
var St=document.getElementById(table.rows[m].cells[1].firstChild.getAttribute('id')).value;
var Sel=document.getElementById(table.rows[m].cells[2].firstChild.getAttribute('id')).value;
if(!Ft) {
Ft=0;
}
if(!St) {
St=0;
}
var to= parseInt(St) * parseInt(Ft);
if(!Sel) {
var tax=0;
} else {
var tax=to*(Sel/100);
}
to=parseInt(to)+parseFloat(tax);
if(Ft && St) {
v=parseFloat(v)+parseFloat(to);
}
}
document.getElementById('total1').value=v;
}
</SCRIPT>





<span style="font-weight:bold;">ADD THIS IN BODY TAG </span>
<textarea rows="10" cols="50">
<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
Total    <input type="text" id="total1" value=''>

<table id="myTable" border="1">
<tr>
<th>Qty</th>
<th>Price</th>
<th>Tax</th>
<th>Add</th>
<th>Delete</th>
</tr>
<tr id="my1Div">

<td><input type='text' onkeyup="total2()" value="" id="my1DivFT" ></td>
<td><input type='text' value='' id="my1DivST" onkeyup="total2()"></td>
<td><select name=select1 id=my1DivSel onchange="total2()">
<option value=''>Select</option>
<option value='1'>Value 1</option>
<option value='2'>Value 2</option>
<option value='3'>Value 3</option>
</select></td>
<td><input type="button" onclick="insRow1('my1Div')" value="Insert row"></td>
</tr>
</table>
</form>

Tuesday, March 23, 2010

Puttanna Kanagal (1933-1985)




Puttanna Kanagal's Directional Movies

Belli Moda (1966) (Silver Cloud)
Mallammana Pavaada (1969) (Mallamma's Magic)
Kappu Bilupu (1969) (Black and White)
Gejje Pooje (1969) (Mock Marriage)
Karulina Kare (1970) (The Voice of Affection)
Sakshatkara (1971) (The Realisation)
Sharapanjara (1971) (Cage of Arrows)
Nagara Haavu (1972) (The Cobra)
Edakallu Guddada Mele (1973) (On the Edakallu Hillock)
Upasane (1974) (The Devotion) starring Aarathi, Seetaram.
Katha Sangama (1975) (Collection of Stories)
Shubhamangala (1975) (Happy Ending)
Bili Hendthi (1975) (White Wife)
Phalithamsha (1976) (The Result)
College Ranga (Kaaleju ranga) (1976) (The College Stage)
Paduvaaralli Pandavaru (1978) (Pandavas of Paduvarahalli)
Dharmasere (1979) (The Religious Bind)
Ranganayaki (1981) (The Heroine of the Stage)
Maanasa Sarovara (1982)
Dharani Mandala Madhyadolage (1983) (At the Centre of Earth)
Amrutha Ghalige (1984) (The Auspicious Moment)
Runamukthalu (1984) (Devoid of Debt)
Masanada Hoovu (1984)
Saavira Mettilu (2006) (Thousand Steps)

Friday, March 12, 2010

Adding dates function in Php and Zend

in zend and php i wrote one small function which is used for adding days,months and year to a date and Format is YYY-MM-dd

Zend
$date = new Zend_Date();
$disbursedDate1='2010-03-11';
$date->set($disbursedDate1,Zend_Date::DATES);
$disbursedDate1=$date->toString("YYY-MM-dd");
$date->set($disbursedDate1,Zend_Date::DATES);
$disbursedDate1=$date->toString("YYY-MM-dd");
$cd = $this->add_dateAction($disbursedDate1,0,1,0);
echo $cd;



Php
$disbursedDate1='2010-03-11';
$cd = $this->add_dateAction($disbursedDate1,0,1,0);
echo $cd;



Function

function add_dateAction($givendate,$day=0,$mth=0,$yr=0)
{
$cd = strtotime($givendate);
$newdate = date('Y-m-d', mktime(date('h',$cd),
date('i',$cd), date('s',$cd), date('m',$cd)+$mth,
date('d',$cd)+$day, date('Y',$cd)+$yr));
return $newdate;
}



Note:- in zend formate is changed so i used this function to over that prob
in Zend default formate is YYYY-DD-MM ,but we can change what every formate we want by Zend_Local

Thursday, February 25, 2010

ಕನ್ನಡ ಕವಿ ,ರಸ್ಟ್ರ-ಕವಿ-ಕುವೆಂಪು

ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!
ರೂಪರೂಪಗಳನು ದಾಟಿ, ನಾಮಕೋಟಿಗಳನು ಮೀಟಿ,
ಎದೆಯ ಬಿರಿಯ ಭಾವ ಬೀಸಿ,
ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!

ನೂರು ಮತದ ಹೊಟ್ಟ ತೂರಿ, ಎಲ್ಲ ತತ್ವದೆಲ್ಲೆ ಮೀರಿ,
ನಿರ್ದಿಗಂತವಾಗಿ ಏರಿ,
ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!

ಎಲ್ಲಿಯೂ ನಿಲ್ಲದಿರು, ಮನೆಯನೆಂದು ಕಟ್ಟದಿರು,
ಕೊನೆಯನೆಂದು ಮುಟ್ಟದಿರು,
ಓ ಅನಂತವಾಗಿರು
ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!

ಅನಂತ ತಾನ್ ಅನಂತವಾಗಿ, ಆಗುತಿಹನೆ ನಿತ್ಯ ಯೋಗಿ,
ಅನಂತ ನೀ ಅನಂತ ವಾಗು, ಆಗು ಆಗು ಆಗು,
ಓ ನನ್ನ ಚೇತನ, ಆಗು ನಿ ಅನಿಕೇತನ!


ಕನ್ನಡ ಕವಿ ,ರಸ್ಟ್ರ-ಕವಿ-ಕುವೆಂಪು

Tuesday, February 23, 2010

ವಿಜಯನಗರದ ವೀರ ಪುತ್ರ

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

ಆಪರ ಕೀತಿಯೆ.........

ಮಾತೆ ತುನ್ಗಭಡ್ರೆ.. ಹರಿಯುತಿಹಲು ಇಲ್ಲಿ
ಮನವನ ಪಪವನು ತೊಳೆವ ಕಲ್ಲ್ಪವಲ್ಲಿ
ಮನವನ ಪಪವನು ತೊಳೆವ ಕಲ್ಲ್ಪವಲ್ಲಿ

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

ಡೆವ ವಿರುಪಕ್ಶ ಈವ ನಮಗೆ ರಕ್ಶೆ
ಜೀವಿಎ ತ ನಿಡುವನು ದರ್ಮದ ಡೀಕ್ಶೆ.....
ಜೀವಿಎ ತ ನಿಡುವನು ದರ್ಮದ ಡೀಕ್ಶೆ.....

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

ಕಡಿದು ಸುಟ್ಟಮುಟ್ಟಲಿತ ಗನ್ಡರನ್ಯ
ಹಕಿಸಿದನು ವಿಜ್ಯನಗರದ ವಿಡ್ಯರನಯ
ಹಕ್ಕಬುಕ್ಕರಲಿ ಭವಯತೆಯನು ತಾಲಿ
ದಿಕ್ಕು ದಿಕ್ಕು ಶನ್ತಿ ಸುಖದ ಕಹಲೆಯ ತೆಲಿ

ಆಪರ ಕೀರ್ತಿ ಗಲಿಸಿ ಮೆರೆವ ಭವ್ಯ ನಾಡಿದು
ಕರ್ನಟವಿದುವೆ ನ್ರಿತ್ಯಶಿಲ್ಪ ಕಲೆಯ ಬಿಡಿದು

Wednesday, February 3, 2010

shopping card



1)index.php
<?php

// Include database connection

require_once('inc/conection.php');

// Include functions

require_once('inc/functions.inc.php');

// Start the session

session_start();

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>PHP Shopping Cart Demo · Bookshop</title>

<link rel="stylesheet" href="css/styles.css" />

</head>



<body>



<div id="shoppingcart">



<h1>Your Shopping Cart</h1>



<?php

echo writeShoppingCart();

?>



</div>



<div id="booklist">



<h1>Books In Our Store</h1>



<?php

$sql = 'SELECT * FROM books ORDER BY id';

$result = $db->query($sql);

$output[] = '<ul>';

while ($row = $result->fetch()) {

$output[] = '<li>"'.$row['title'].'" by '.$row['author'].': £'.$row['price'].'<br /><a href="cart.php?action=add&id='.$row['id'].'">Add to cart</a></li>';

}

$output[] = '</ul>';

echo join('',$output);

?>



</div>



</body>

</html>

2)cart.php
<?php

// Include database connection

require_once('inc/conection.php');

// Include functions

require_once('inc/functions.inc.php');

// Start the session

session_start();

// Process actions

$cart = $_SESSION['cart'];

$action = $_GET['action'];

switch ($action) {

case 'add':

if ($cart) {

$cart .= ','.$_GET['id'];

} else {

$cart = $_GET['id'];

}
echo '<script type="text/javascript">
<!--
window.location = "cart.php"
//-->
</script>
';
break;

case 'delete':

if ($cart) {

$items = explode(',',$cart);

$newcart = '';

foreach ($items as $item) {

if ($_GET['id'] != $item) {

if ($newcart != '') {

$newcart .= ','.$item;

} else {

$newcart = $item;

}

}

}

$cart = $newcart;

}

break;

case 'update':

if ($cart) {

$newcart = '';

foreach ($_POST as $key=>$value) {

if (stristr($key,'qty')) {

$id = str_replace('qty','',$key);

$items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart);

$newcart = '';

foreach ($items as $item) {

if ($id != $item) {

if ($newcart != '') {

$newcart .= ','.$item;

} else {

$newcart = $item;

}

}

}

for ($i=1;$i<=$value;$i++) {

if ($newcart != '') {

$newcart .= ','.$id;

} else {

$newcart = $id;

}

}

}

}

}

$cart = $newcart;

break;

}

$_SESSION['cart'] = $cart;

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>PHP Shopping Cart Demo · Cart</title>

<link rel="stylesheet" href="css/styles.css" />

</head>



<body>



<div id="shoppingcart">



<h1>Your Shopping Cart</h1>



<?php

echo writeShoppingCart();

?>



</div>



<div id="contents">



<h1>Please check quantities...</h1>



<?php

echo showCart();

?>



<p><a href="index.php">Back to bookshop...</a></p>



</div>



</body>

</html>

3)funtion.inc.php


<?php

function writeShoppingCart() {

$cart = $_SESSION['cart'];

if (!$cart) {

return '<p>You have no items in your shopping cart</p>';

} else {

// Parse the cart session variable

$items = explode(',',$cart);

$s = (count($items) > 1) ? 's':'';

return '<p>You have <a href="cart.php">'.count($items).' item'.$s.' in your shopping cart</a></p>';

}

}



function showCart() {

global $db;

$cart = $_SESSION['cart'];

if ($cart) {

$items = explode(',',$cart);

$contents = array();

foreach ($items as $item) {

$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;

}

$output[] = '<form action="cart.php?action=update" method="post" id="cart">';

$output[] = '<table>';

foreach ($contents as $id=>$qty) {

$sql = 'SELECT * FROM books WHERE id = '.$id;

$result = $db->query($sql);

$row = $result->fetch();

extract($row);

$output[] = '<tr>';

$output[] = '<td><a href="cart.php?action=delete&id='.$id.'" class="r">Remove</a></td>';

$output[] = '<td>'.$title.' by '.$author.'</td>';

$output[] = '<td>£'.$price.'</td>';

$output[] = '<td><input type="text" name="qty'.$id.'" value="'.$qty.'" size="3" maxlength="3" /></td>';

$output[] = '<td>£'.($price * $qty).'</td>';

$total += $price * $qty;

$output[] = '</tr>';

}

$output[] = '</table>';

$output[] = '<p>Grand total: <strong>£'.$total.'</strong></p>';

$output[] = '<div><button type="submit">Update cart</button></div>';

$output[] = '</form>';

} else {

$output[] = '<p>You shopping cart is empty.</p>';

}

return join('',$output);

}

?>

4)connection.php

<?php

session_start();
$conn=mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("cart",$conn) or die(mysql_error());
?>





create cart.sql file and paste this code

//start

-- phpMyAdmin SQL Dump
-- version 2.11.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 07, 2010 at 08:39 PM
-- Server version: 5.0.51
-- PHP Version: 5.2.5

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `cart`
--

-- --------------------------------------------------------

--
-- Table structure for table `books`
--

CREATE TABLE IF NOT EXISTS `books` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(30) NOT NULL,
`author` varchar(30) NOT NULL,
`price` float(10,2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `books`
--

INSERT INTO `books` (`id`, `title`, `author`, `price`) VALUES
(1, 'five point some one', 'Chethan Bhagth', 400.00);


//end


import to phpmyadmin