totaal prijs
de bedoeling is dat hij een totaal prijs moet laten zien
dit heb ik gedownload van internet en probeer het in een menu te zetten
gr thymen
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/global.inc.php');
// Include functions
require_once('inc/functions.inc.php');
// Start the session
session_start();
$sql = 'SELECT * FROM books ORDER BY id';
$result = $db->query($sql);
$total += $price * $qty;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.tb {
border-bottom:1px dotted #8c8c8c;
}
</style>
<title>Untitled Document</title>
</head>
<body>
<p><h4>Acount gegevens</h4></span></p>
<a href="index.php?page=a_edit">Acount bewerken</a>
<br />
<a href="index.php?page=a_trace">Mijn bestelling traceren</a>
<br />
<a href="index.php?page=uitloggen" onclick="return confirm('Ben je zeker dat je je wilt afmelden?');"><u>Uitloggen</u></a>
<br />
<br />
<p><h4>Winkelwagen</h4></span></p>
</p>
<table class="tb" width="180" height="171" >
<tr>
<td class="tb" height="130">
<p>
<?php
echo writeShoppingCart();
?>
</p></td>
</tr>
<tr>
<td><p>Totaal: <strong>€<?php '.$total.'?></strong></p></td>
</tr>
</table>
<p> </p>
</body>
</html>
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/global.inc.php');
// Include functions
require_once('inc/functions.inc.php');
// Start the session
session_start();
$sql = 'SELECT * FROM books ORDER BY id';
$result = $db->query($sql);
$total += $price * $qty;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.tb {
border-bottom:1px dotted #8c8c8c;
}
</style>
<title>Untitled Document</title>
</head>
<body>
<p><h4>Acount gegevens</h4></span></p>
<a href="index.php?page=a_edit">Acount bewerken</a>
<br />
<a href="index.php?page=a_trace">Mijn bestelling traceren</a>
<br />
<a href="index.php?page=uitloggen" onclick="return confirm('Ben je zeker dat je je wilt afmelden?');"><u>Uitloggen</u></a>
<br />
<br />
<p><h4>Winkelwagen</h4></span></p>
</p>
<table class="tb" width="180" height="171" >
<tr>
<td class="tb" height="130">
<p>
<?php
echo writeShoppingCart();
?>
</p></td>
</tr>
<tr>
<td><p>Totaal: <strong>€<?php '.$total.'?></strong></p></td>
</tr>
</table>
<p> </p>
</body>
</html>
dat was mijn code maar hij laat geen totaal prijs zien en ik zie niet wat er nou fout is
nu het hele script: word lange pagina dit :p
(functies)
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
function writeShoppingCart() {
$cart = $_SESSION['cart'];
if (!$cart) {
return '<p>U heeft geen bestellingen geplaatst</p>';
} else {
// Parse the cart session variable
$items = explode(',',$cart);
$s = (count($items) > 1) ? 's':'';
return '<p>Je hebt <a href="cart.php">'.count($items).' item'.$s.' in je winkel wagen.</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);
}
?>
function writeShoppingCart() {
$cart = $_SESSION['cart'];
if (!$cart) {
return '<p>U heeft geen bestellingen geplaatst</p>';
} else {
// Parse the cart session variable
$items = explode(',',$cart);
$s = (count($items) > 1) ? 's':'';
return '<p>Je hebt <a href="cart.php">'.count($items).' item'.$s.' in je winkel wagen.</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);
}
?>
(globals)
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<?php
$host = 'localhost';
$user = 'root';
$pass = 'vertrigo';
$name = 'cart';
$db = &new MySQL($host,$user,$pass,$name);
?>
$host = 'localhost';
$user = 'root';
$pass = 'vertrigo';
$name = 'cart';
$db = &new MySQL($host,$user,$pass,$name);
?>
mysqlclass
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<?php
/**
* MySQL Database Connection Class
* @access public
* @package SPLIB
*/
class MySQL {
/**
* MySQL server hostname
* @access private
* @var string
*/
var $host;
/**
* MySQL username
* @access private
* @var string
*/
var $dbUser;
/**
* MySQL user's password
* @access private
* @var string
*/
var $dbPass;
/**
* Name of database to use
* @access private
* @var string
*/
var $dbName;
/**
* MySQL Resource link identifier stored here
* @access private
* @var string
*/
var $dbConn;
/**
* Stores error messages for connection errors
* @access private
* @var string
*/
var $connectError;
/**
* MySQL constructor
* @param string host (MySQL server hostname)
* @param string dbUser (MySQL User Name)
* @param string dbPass (MySQL User Password)
* @param string dbName (Database to select)
* @access public
*/
function MySQL ($host,$dbUser,$dbPass,$dbName) {
$this->host=$host;
$this->dbUser=$dbUser;
$this->dbPass=$dbPass;
$this->dbName=$dbName;
$this->connectToDb();
}
/**
* Establishes connection to MySQL and selects a database
* @return void
* @access private
*/
function connectToDb () {
// Make connection to MySQL server
if (!$this->dbConn = @mysql_connect($this->host,
$this->dbUser,
$this->dbPass)) {
trigger_error('Could not connect to server');
$this->connectError=true;
// Select database
} else if ( !@mysql_select_db($this->dbName,$this->dbConn) ) {
trigger_error('Could not select database');
$this->connectError=true;
}
}
/**
* Checks for MySQL errors
* @return boolean
* @access public
*/
function isError () {
if ( $this->connectError )
return true;
$error=mysql_error ($this->dbConn);
if ( empty ($error) )
return false;
else
return true;
}
/**
* Returns an instance of MySQLResult to fetch rows with
* @param $sql string the database query to run
* @return MySQLResult
* @access public
*/
function query($sql) {
if (!$queryResource=mysql_query($sql,$this->dbConn))
trigger_error ('Query failed: '.mysql_error($this->dbConn).
' SQL: '.$sql);
return new MySQLResult($this,$queryResource);
}
}
/**
* MySQLResult Data Fetching Class
* @access public
* @package SPLIB
*/
class MySQLResult {
/**
* Instance of MySQL providing database connection
* @access private
* @var MySQL
*/
var $mysql;
/**
* Query resource
* @access private
* @var resource
*/
var $query;
/**
* MySQLResult constructor
* @param object mysql (instance of MySQL class)
* @param resource query (MySQL query resource)
* @access public
*/
function MySQLResult(& $mysql,$query) {
$this->mysql=& $mysql;
$this->query=$query;
}
/**
* Fetches a row from the result
* @return array
* @access public
*/
function fetch () {
if ( $row=mysql_fetch_array($this->query,MYSQL_ASSOC) ) {
return $row;
} else if ( $this->size() > 0 ) {
mysql_data_seek($this->query,0);
return false;
} else {
return false;
}
}
/**
* Returns the number of rows selected
* @return int
* @access public
*/
function size () {
return mysql_num_rows($this->query);
}
/**
* Returns the ID of the last row inserted
* @return int
* @access public
*/
function insertID () {
return mysql_insert_id($this->mysql->dbConn);
}
/**
* Checks for MySQL errors
* @return boolean
* @access public
*/
function isError () {
return $this->mysql->isError();
}
}
?>
/**
* MySQL Database Connection Class
* @access public
* @package SPLIB
*/
class MySQL {
/**
* MySQL server hostname
* @access private
* @var string
*/
var $host;
/**
* MySQL username
* @access private
* @var string
*/
var $dbUser;
/**
* MySQL user's password
* @access private
* @var string
*/
var $dbPass;
/**
* Name of database to use
* @access private
* @var string
*/
var $dbName;
/**
* MySQL Resource link identifier stored here
* @access private
* @var string
*/
var $dbConn;
/**
* Stores error messages for connection errors
* @access private
* @var string
*/
var $connectError;
/**
* MySQL constructor
* @param string host (MySQL server hostname)
* @param string dbUser (MySQL User Name)
* @param string dbPass (MySQL User Password)
* @param string dbName (Database to select)
* @access public
*/
function MySQL ($host,$dbUser,$dbPass,$dbName) {
$this->host=$host;
$this->dbUser=$dbUser;
$this->dbPass=$dbPass;
$this->dbName=$dbName;
$this->connectToDb();
}
/**
* Establishes connection to MySQL and selects a database
* @return void
* @access private
*/
function connectToDb () {
// Make connection to MySQL server
if (!$this->dbConn = @mysql_connect($this->host,
$this->dbUser,
$this->dbPass)) {
trigger_error('Could not connect to server');
$this->connectError=true;
// Select database
} else if ( !@mysql_select_db($this->dbName,$this->dbConn) ) {
trigger_error('Could not select database');
$this->connectError=true;
}
}
/**
* Checks for MySQL errors
* @return boolean
* @access public
*/
function isError () {
if ( $this->connectError )
return true;
$error=mysql_error ($this->dbConn);
if ( empty ($error) )
return false;
else
return true;
}
/**
* Returns an instance of MySQLResult to fetch rows with
* @param $sql string the database query to run
* @return MySQLResult
* @access public
*/
function query($sql) {
if (!$queryResource=mysql_query($sql,$this->dbConn))
trigger_error ('Query failed: '.mysql_error($this->dbConn).
' SQL: '.$sql);
return new MySQLResult($this,$queryResource);
}
}
/**
* MySQLResult Data Fetching Class
* @access public
* @package SPLIB
*/
class MySQLResult {
/**
* Instance of MySQL providing database connection
* @access private
* @var MySQL
*/
var $mysql;
/**
* Query resource
* @access private
* @var resource
*/
var $query;
/**
* MySQLResult constructor
* @param object mysql (instance of MySQL class)
* @param resource query (MySQL query resource)
* @access public
*/
function MySQLResult(& $mysql,$query) {
$this->mysql=& $mysql;
$this->query=$query;
}
/**
* Fetches a row from the result
* @return array
* @access public
*/
function fetch () {
if ( $row=mysql_fetch_array($this->query,MYSQL_ASSOC) ) {
return $row;
} else if ( $this->size() > 0 ) {
mysql_data_seek($this->query,0);
return false;
} else {
return false;
}
}
/**
* Returns the number of rows selected
* @return int
* @access public
*/
function size () {
return mysql_num_rows($this->query);
}
/**
* Returns the ID of the last row inserted
* @return int
* @access public
*/
function insertID () {
return mysql_insert_id($this->mysql->dbConn);
}
/**
* Checks for MySQL errors
* @return boolean
* @access public
*/
function isError () {
return $this->mysql->isError();
}
}
?>
cart.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/global.inc.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'];
}
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>
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/global.inc.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'];
}
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>
en orginele index
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/global.inc.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>
// Include MySQL class
require_once('inc/mysql.class.php');
// Include database connection
require_once('inc/global.inc.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>
db:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
CREATE TABLE books (
id int(6) unsigned NOT NULL auto_increment,
title varchar(100) NOT NULL default '',
author varchar(100) NOT NULL default '',
price decimal(3,2) NOT NULL default '0.00',
PRIMARY KEY (id)
) TYPE=MyISAM;
INSERT INTO books VALUES (1, 'Where God Went Wrong', 'Oolon Colluphid', '24.99');
INSERT INTO books VALUES (2, 'Some More of God\'s Greatest Mistakes', 'Oolon Colluphid', '17.99');
INSERT INTO books VALUES (3, 'Who Is This God Person Anyway?', 'Oolon Colluphid', '14.99');
id int(6) unsigned NOT NULL auto_increment,
title varchar(100) NOT NULL default '',
author varchar(100) NOT NULL default '',
price decimal(3,2) NOT NULL default '0.00',
PRIMARY KEY (id)
) TYPE=MyISAM;
INSERT INTO books VALUES (1, 'Where God Went Wrong', 'Oolon Colluphid', '24.99');
INSERT INTO books VALUES (2, 'Some More of God\'s Greatest Mistakes', 'Oolon Colluphid', '17.99');
INSERT INTO books VALUES (3, 'Who Is This God Person Anyway?', 'Oolon Colluphid', '14.99');
idd :p maar het werkt nu nog steeds niej :(
Zet dit boven je script:
error_reporting(E_ALL);
ini_set("display_errors", 1);
Post vervolgens de errors, en de een stukje rond de regels die de errors aangeven
Gewijzigd op 01/01/1970 01:00:00 door Pepijn
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Program Files\VertrigoServ\www\cart\index3.php:2) in C:\Program Files\VertrigoServ\www\cart\index3.php on line 12
en ik heb deze
Code (php)
1
Notice: Undefined variable: total in C:\Program Files\VertrigoServ\www\cart\index3.php on line 52
Gewijzigd op 01/01/1970 01:00:00 door thymen
session_start(); helemaal bovenaan je script zetten.
Notice: Undefined variable: total in C:\Program Files\VertrigoServ\www\cart\index3.php on line 53
op line 53 staat <td><p>Totaal: <strong>€</strong></p></td>
$total staat er idd niet in maar wat moet ik daar in zetten dat hij automaties alles bij elkaar opteld
ik had eerst
$total += $price * $qty;
maar dat werrkt ook niet :(
Gewijzigd op 01/01/1970 01:00:00 door thymen
http://crocopep.awardspace.com/cart
Zelf even de extensie .zip erachter zetten. En de pagina global.inc.php aanpassen
Gewijzigd op 01/01/1970 01:00:00 door Pepijn
probleem opgelost het was gewoon allemaal een kwestie van kijken topic closed thnx ;)
Gewijzigd op 01/01/1970 01:00:00 door thymen