| Message # 1025446: |
Date: 04/28/05 13:30
By: Asia
Subject: RE: Shopping Cart
Im a php beginner and i wanted to know how i can add products to the shopping basket. the code i have at the moment is something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<?php
//Define any local constants
//*include 'Constant.inc'; //Defines the contants needed to connect to the database*//
define ("YOUR_USERNAME", "");
define ("YOUR_PASSWORD", "");
define ("YOUR_DATABASE", "");
define ("YOUR_DBMS_SERVER", "helios.hud.ac.uk");
//Define any local functions
function showError()
{
//Display error number and description, then exit gracefully
die("\nError " . mysql_errno() . " : " . mysql_error());
}
//Initialize local variables with GET and POST parameter values
$ucasCode=$_GET["ucasCode"];
$pathway=$_GET["title"];
$level=$_GET["level"];
$qualification=$_GET["qualification"];
$description=$_GET["description"];
/*PORTFOLIO WORK
1) For the basic behaviour, capture the username and password, which were sent
as HTML Form parameter values from ListPathway.php, for use later on.
2) For the advanced bahviour, check that the user has already logged in, and if
not put up an error message.
*/
?>
<head>
<title>Pennine University course catalogue</title>
</head>
<body>
<h1>Pathway detail</h1>
<p> You requested the following pathway details.
</p>
<?php
$connection = @ mysql_connect(YOUR_DBMS_SERVER, YOUR_USERNAME, YOUR_PASSWORD);
if ($connection==FALSE)
die("\nCould not connect " . YOUR_USERNAME . " to " . YOUR_DBMS_SERVER);
else
//This de-bug message should be removed in the final version of the script
echo "\n<!-- Connected " . YOUR_USERNAME . " to " . YOUR_DBMS_SERVER . "-->";
$database = @ mysql_select_db(YOUR_DATABASE, $connection);
if ($database == FALSE)
showError();
else
//This de-bug message should be removed in the final version of the script
echo "\n<!-- Using database " . YOUR_DATABASE . "-->";
//Create the SQL statement to retrieve the pathway details;
$sql = "SELECT level, qualification, title, ucasCode, description
FROM Pathway
WHERE ucasCode = '$ucasCode';";
$result = @ mysql_query($sql, $connection);
if ($result == FALSE)
{
echo "\n<!-- SQL query \n".$sql."\nFAILED. -->\n";
showerror();
}
else
{
//This de-bug message should be removed in the final version of the script
echo "\n<!-- SQL query \n".$sql."\nworked. -->\n";
}
//Fetch a row (i.e. pathway details) from the result set;
$pathway = mysql_fetch_array($result);
/*PORTFOLIO WORK
1) For the basic behaviour, amend this code to use a HTML Form to include two
buttons: "Add to basket" and "View basket". "Add to basket" should add the
current pathway to the shopping basket.
*/
//Display the pathway name
$rows=mysql_num_rows($result);
echo ("<table border=1><tr><th>Title</th>");
echo ("<th>Ucas Code</th><th>Level</th>");
echo ("<th>Qualification</th><th>Description</th></tr>");
for ($rowcount=0;$rowcount<$rows;$rowcount++)
{
echo "\n <th> " . $pathway["title"];
echo "\n <th> " . $pathway["ucasCode"];
echo "\n <th> " . $pathway["level"];
echo "\n <th> " . $pathway["qualification"];
echo "\n <th> " . $pathway["description"];
echo "\n</pre>\n";
echo ("<tr>");
$datarow=mysql_fetch_row($result);
{
echo("<td>$datarow[$colcount]</td>");
}
echo ("</tr>");
}
echo ("</table>");
/*END OF PORTFOLIO WORK*/
//Now close the database connection
mysql_close($connection);
?>
<form method=POST action=ManageBasket.php>
<input type="submit" value="Add to Basket">
</form>
</body></html>
can somebody help me im desperate for help.
thankyou
|
Previous Message | Next Message
|
| Comments: |
| Shop | Armen | 05/14/08 13:01 |
| RE: latest software of PHP | prosenjit das | 11/16/05 01:52 |
| Php shop Shopping Basket Problem | marc | 11/01/05 07:28 |
| weird cart showing up | kitaeshi | 05/02/05 08:57 |
| RE: Shopping Cart | Asia | 04/28/05 13:30 |
| need help with basket | Rob | 04/13/05 03:45 |
| page indexing in array | ashramsuswal | 03/01/05 09:30 |
| why ???? | wapweb | 02/17/05 23:22 |
| how to add to the basket using java servlets | arshiya | 02/11/05 00:01 |
| RE: Adding, Deleting, Updating. Examples: | tania | 12/11/04 00:51 |
| RE: Adding, Deleting, Updating. Examples: | tania | 12/11/04 00:37 |
| RE: final version? | Jim Fletcher | 04/11/04 21:40 |
| Subject: Updatet Script to become class | Gerrit ZAAIJER | 12/29/03 19:52 |
| Link Doesn't Work | Evan | 08/27/03 21:15 |
| RE: Error? | Carl | 08/12/03 08:53 |
| RE: Adding, Deleting, Updating. Examples: | Heikki | 07/25/03 04:02 |
| Adding, Deleting, Updating. Examples: | Ben | 06/22/03 17:54 |
| final version? | Termee | 04/17/03 15:27 |
| RE: Anyone using this on a site yet? | Evert | 03/31/03 06:14 |
| RE: Anyone using this on a site yet? | Carlton Fletcher | 03/24/03 15:45 |
| RE: How to remove products from Basket ???? | Stephen Robinson | 02/06/03 05:19 |
| RE: Cannot send session cache limite | Stephen Robinson | 02/06/03 05:17 |
| RE: Delete in minibasket | Stephen Robinson | 02/06/03 05:15 |
| hot to emptry whole basket | Stephen Robinson | 02/06/03 05:12 |
| RE: Inputting data into a database | bruc wells | 01/20/03 10:11 |
| RE: Here an example how to uise the class | Matt Pritchard | 01/07/03 04:11 |
| Simplest PHP4 shoping basket | João Barradas | 12/23/02 14:38 |
| I converted the basket for PHP4.20 and higher | Marco Simons | 12/06/02 08:08 |
| RE: cart using session arrays | punknroll | 10/24/02 12:03 |
| cart using session arrays | Benno | 10/20/02 03:52 |
| Example using Class | lsimon | 10/19/02 13:38 |
| updatecart=0 | Lindsey Simon | 10/18/02 16:12 |
| Here an example how to uise the class | Evert | 10/18/02 11:40 |
| example using new basket class | lsimon | 10/16/02 20:38 |
| answers to include, delete reload etc | Evert Smit | 10/10/02 10:09 |
| Click reload button on browser | Jason | 10/08/02 14:04 |
| Evert.inc ?? | Jens | 10/08/02 09:02 |
| Error? | Jens | 10/08/02 08:57 |
| RE: deleting items from basket | evelyn | 10/04/02 05:39 |
| RE: how do you change # of certain product | Evert Smit | 09/26/02 13:05 |
| how do you change # of certain product | DEREK | 09/23/02 18:35 |
| Updatet Script to become class | Evert Smit | 09/16/02 04:44 |
| Deleting Items Indivually from the Cart | Andrew | 09/05/02 06:56 |
| RE: totaling up | Andrew | 09/03/02 15:20 |
| Demo shop | frode nystad | 08/12/02 20:06 |
| dont forget to put the session_start() at the | Eli Vaknin | 07/25/02 19:52 |
| Good script | Unknown | 07/14/02 16:37 |
| How to make a Recurring Billing System w/ PHP | Nick | 06/25/02 06:02 |
| Code in use | Antonio "Antimax" Araujo | 06/21/02 23:09 |
| RE: Shopping Cart | cliffdweller | 06/04/02 20:44 |
| Shopping Cart | Debbie | 05/28/02 20:35 |
| totaling up | Hargs | 05/03/02 06:21 |
| RE: what is the html code to add item to cart! | Hargs | 05/03/02 06:16 |
| porting this example to a php class with OO | Evert Smit | 02/22/02 04:45 |
| RE: what is the html code to add item to cart! | Evert Smit | 02/22/02 04:36 |
| RE: empty cart added and solved refresh problem. | Evert Smit | 02/22/02 04:34 |
| what is the html code to add item to cart! | Rydell Shah | 02/18/02 12:07 |
| RE: deleting items from basket | JoeyG | 02/14/02 19:46 |
| Ordering System | Donna | 02/13/02 10:12 |
| RE: deleting items from basket | JoeyG | 02/12/02 18:46 |
| RE: deleting items from basket | JoeyG | 02/06/02 19:14 |
| RE: what about the reload button | JoeyG | 02/06/02 19:05 |
| RE: Why the code does not work | mike | 02/03/02 04:12 |
| RE: empty cart added and solved refresh problem. | Andrew Salmons | 01/06/02 16:27 |
| php session | shams | 12/27/01 04:50 |
| coping with session expiration | Ben | 12/04/01 19:12 |
| empty cart added and solved refresh problem. | Zane Amiralis | 11/21/01 18:43 |
| RE: Anyone using this on a site yet? | tfg1 | 10/26/01 09:50 |
| Regarding this example | Evert Smit | 10/20/01 16:07 |
| RE: Bad Idea here - Insecure | Evert | 10/20/01 15:59 |
| RE: help me out with this one please | Evert | 10/20/01 15:54 |
| RE: Inputting data into a database | Evert | 10/20/01 15:52 |
| RE: Displaying the basket on a different page | Evert | 10/20/01 15:49 |
| RE: Session vars get reset! | Ian | 10/15/01 18:13 |
| Session vars get reset! | Ian | 10/15/01 12:18 |
| Displaying the basket on a different page | Luke | 10/02/01 21:38 |
| PHP4 Session class | G|ga | 10/02/01 06:40 |
| RE: Why the code does not work | xinkun | 09/25/01 12:17 |
| DESTROY THE SESSION | loreto mateu | 09/04/01 11:01 |
| Inputting data into a database | Tom Hemsley | 08/29/01 08:11 |
| how difficult is it to put up correct codes?? | viren | 08/21/01 22:35 |
| help me out with this one please | joe Bestler | 08/21/01 09:33 |
| Delete in minibasket | jeff | 07/05/01 13:41 |
| RE: Why the code does not work | John McGarry | 06/25/01 07:53 |
| not running | Dino | 05/17/01 10:22 |
| RE: what about the reload button | Chunhui | 05/16/01 10:25 |
| RE: Sessions how... | Jeff Lambert | 05/15/01 21:29 |
| RE: Bad Idea here - Insecure | Jeff Lambert | 05/15/01 21:26 |
| Sessions... Further in online/offline | Richard | 05/10/01 08:29 |
| what about the reload button | Pitter | 04/29/01 08:16 |
| RE: Bad Idea here - Insecure | Ollie | 04/25/01 17:21 |
| Make some cents!!! | Simon Pritchard | 04/02/01 23:06 |
| re: bad idea, insecure | fandelem | 04/01/01 22:41 |
| Bad Idea here - Insecure | Todd | 03/19/01 11:55 |
| Item names with multiple words | Andy Lewis | 03/04/01 21:39 |
| Anyone using this on a site yet? | Mike Seiler | 03/04/01 12:03 |
| Cannot send session cache limite | Marc Weller | 02/28/01 03:33 |
| RE: Cannot add header information | Daniel | 02/27/01 07:16 |
| How to remove products from Basket ???? | Neville | 02/25/01 18:43 |
| RE: Warning: var. basket is undefined | Jahu | 02/23/01 08:26 |
| Warning: var. basket is undefined | Victoria Afonina | 02/20/01 16:31 |
| deleting items from basket | Brian | 02/05/01 10:07 |
| Warnings when starting.. | Hans-Jörg Alles | 02/01/01 09:40 |
| RE: Why the code does not work | everal rimbald | 01/21/01 09:53 |
| Willing to buy prepackaged code | Ron Kwok | 01/05/01 10:28 |
| Posting to different page. | brian | 01/04/01 18:55 |
| Why the code does not work | Greg Militelo | 01/02/01 16:07 |
| Zip file | Stephanie | 12/27/00 14:14 |
| Howto check for session without creating one? | Jed Baer | 12/22/00 11:51 |
| RE: Not Working | Greg Trepanier | 12/05/00 14:14 |
| RE: Cookie security | Keith Davis | 11/20/00 19:55 |
| About cut and paste | Fernando | 10/24/00 15:52 |
| Strange script... - part 2 (read the end!) | Jens | 10/09/00 16:22 |
| Not Working | Chris Toole | 09/11/00 23:16 |
| Cannot add header information | Randy | 09/11/00 11:27 |
| RE: Sessions how... | Martin | 09/07/00 03:21 |
| RE: Sessions how... | nico | 09/01/00 19:12 |
| Security problem! | spencer p | 08/31/00 11:08 |
| RE: Browser's Back Buttom | Vincent Lam | 08/29/00 03:05 |
| RE: Why can't I get it works ? | Evert Smit | 08/28/00 16:39 |
| RE: Cannot send session ?? please help | James Hsieh | 08/27/00 05:14 |
| Why can't I get it works ? | James Hsieh | 08/27/00 05:04 |
| RE: Cannot send session ?? please help | Evert Smit | 08/25/00 04:32 |
| RE: Sessions how... | Evert Smit | 08/25/00 04:29 |
| RE: Browser's Back Buttom | Vince | 08/24/00 17:15 |
| RE: Browser's Back Buttom | Vince | 08/24/00 11:50 |
| Sessions how... | Martin | 08/23/00 16:23 |
| RE: Cannot send session ?? please help | Martin | 08/23/00 16:16 |
| Cannot send session ?? please help | Gorazd Majcenovic | 08/23/00 15:07 |
| RE: Browser's Back Buttom | Richard Heyes | 08/20/00 07:56 |
| RE: Cookie security | Evert Smit | 08/18/00 06:03 |
| RE: Browser's Back Buttom | Evert Smit | 08/18/00 06:00 |
| Browser's Back Buttom | Manuel Durán Aguete | 08/18/00 05:08 |
| RE: Cookie security | Martin Wheatley | 08/17/00 12:49 |
| Cookie security | Vesa Nippala | 08/17/00 01:30 |
| Yes, you can store objects. | Robert | 08/16/00 11:15 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.
|