Jump to content

Search the Community

Showing results for tags 'shoppingcart'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 2 results

  1. Hello, I am trying to load a txt file into mysql -uroot to create a database with all the tables and everything is prewritten. Here is what I thought I was supposed to write (but it's not working): mysql -uroot < skel_mysql.txt the skel_mysql.txt file is located in xampp/mysql/bin and this is a copy of the text in the file. CREATE DATABASE skel; USE skel; CREATE TABLE customers ( ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT, LAST CHAR(20) NOT NULL, FIRST CHAR(20) NOT NULL, PHONE CHAR(20) NOT NULL, SESSID CHAR(32) NOT NULL ); CREATE TABLE products ( SKU INT NOT NULL PRIMARY KEY, NAME CHAR(20) NOT NULL, DESCR VARCHAR(40) NOT NULL, PRICE DECIMAL(9,2) NOT NULL, IMAGE VARCHAR(20) NOT NULL ); INSERT INTO products VALUES(1121,'Small Lab Coat','White Lab Coat Adult Small',15.75,'labcoat.png'), (1122,'Medium Lab Coat','White Lab Coat Adult Medium',15.75,'labcoat.png'), (1123,'Large Lab Coat','White Lab Coat Adult Large',16.75,'labcoat.png'), (1124,'Beaker Kit','Set of 5 different beakers',22.05,'beakers.png'), (1125,'Petri Dishes','Set of three',9.99,'petri.png'), (1126,'Safety Glasses','Women's Safety Glasses',15.75,'wmglass.png'), (1127,'Mens Safety Glasses','Men's Safety Glasses',15.75,'mglass.png'), (1128,'Kids Safety Glasses','Kid's Safety Glasses',15.75, 'kglass.png'), ; CREATE TABLE cart ( ID CHAR(32) NOT NULL, DATE DATETIME NOT NULL, QTY INT NOT NULL, SKU INT NOT NULL ); Side note: I thought there was an error in my database so I dropped it and rewrote the code in a txt file and now I dont want to rewrite everything in the cmd prompt. This is for a simple shopping cart assignment Im doing for a PHP class.
  2. i want to design a shopping cart without using a database, presently, i have a code but users have to input the price of their product, i want to change that, so that the prices would be determined by the the quantity. below is the form i've created: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd[/url]"> <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml[/url]" xml:lang="en"> <head> <title>My Sessions </title> </head> <body> <form method="post" action="order.php"> <p> Mouse: </br> <input type="text" name="mouse" size="3" <?php if ( $_POST['mouse'] ) { print ' value="' . $_POST['mouse'] . '"'; } ?> > at $10.99 each </p> <p> Dell Laptop: </br> <input type="text" name="dell" size="3" <?php if ( $_POST['dell'] ) { print ' value="' . $_POST['dell'] . '"'; } ?> > at $20.99 each </p> <p> Ipad: </br> <input type="text" name="ipad" size="3" <?php if ( $_POST['ipad'] ) { print ' value="' . $_POST['ipad'] . '"'; } ?> > at $30.95 each </p> <p> Iphone: </br> <input type="text" name="iphone" size="3" <?php if ( $_POST['iphone'] ) { print ' value="' . $_POST['iphone'] . '"'; } ?> > at $40.95 each </p> <p> Blackberry: </br> <input type="text" name="blackberry" size="3" <?php if ( $_POST['blackberry'] ) { print ' value="' . $_POST['blackberry'] . '"'; } ?> > at $50.95 each </p> <p> <button type="submit">Add to cart</button> </p> </form> <form action="clearcart.php" method="post"> <p><input type="submit" value="Clear Cart" /></p> </form> <hr /> <p><a href="cart.php">Go to my cart</a></p> </body> </html> the form above is a new form, my problem is how do i fix in prices into my already written shopping cart code which is below. i'd appreciate it if any one can help with a new code that would accept the and fix prices, quantity and products into a cart. below is my already written code: <?php #We used the superglobal $_GET here /*if (!($_GET['name'] && $_GET['email'] && $_GET['password'])) { #with the header() function, no output can come before it. #echo "Please make sure you've filled in all required information."; $query_string = $_SERVER['QUERY_STRING']; header("Location: ".$url); exit(); } extract($_GET, EXTR_PREFIX_SAME, "get");*/ echo date("F d, Y h:i a"); /*function email_mesg($data_array, $template_file) { #get template contents, and replace variables with data $email_message = str_replace("#name#", $data_array['name'], $email_message); $email_message = str_replace("#email#", $data_array['email'], $email_message); email_mesg($_GET, $_SERVER['DOCUMENT_ROOT']."/myemail_template.txt");*/ //Start the session session_start(); $customer_name = $_SESSION['name']; if (!($customer_name)) { $customer_name = $_GET['name']; } $customer_email = $_SESSION['email']; if (!($customer_email)) { $customer_email = $_GET['email']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/url]"> <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml[/url]" xml:lang="en"> <head> <title>Efe Shopping Cart</title> </head> <body> <form action="checkout.php" method="post"> <p><input type="submit" value="Checkout" /></p> </form> <h1>Efe Shopping Cart</h1> <?php $products = array ( array("productname" => "blackberry", "price" => "59.99", "description" => "Blackberry mobile phone"), array("productname" => "Mouse", "price" => "12.95", "description" => "Gaming mouse. 9200 DPI"), array("productname" => "iPad", "price" => "100.59", "description" => "The new apple ipad"), array("productname" => "Dell laptop", "price" => "250.00", "description" => "The best dell laptop available."), array("productname" => "iphone", "price" => "170.99", "description" => "The new iphone 5.") ); echo "<pre>"; print_r($products); echo "</pre>"; //If we have previously initiated a session in addtocart.php, the shopping cart is //defined as an associative array, $_SESSION['cart']. //check if the $_SESSION['cart'] variable has been defined, as it //won't be if the user has come straight to this page. //check if there are currently any items in the shopping cart. if (isset($_GET['remember'])) { #the customer wants us to remember him/her for next time $_SESSION['name'] = $customer_name; $_SESSION['email'] = $customer_email; } if (!isset($_SESSION['cart']) || (count($_SESSION['cart']) == 0)) { echo '<p>The cart is empty.</p>'; } else { echo '<table border="1"> <tr><th>Item</th><th>Unit price</th><th>No. of units</th><th>Subtotal</th></tr>'; $total = 0; //iterate over all the items in $_SESSION['cart']. //Each item represents a "row," or a single product to buy, in the shopping cart. foreach($_SESSION['cart'] as $item) //note that the format of the $item associative array is the same as the one //defined in addtocart.php, since the array has simply been passed to this page //via the $_SESSION variable. { echo "<tr><td>{$item['item']} </td><td>\${$item['unitprice']}</td><td>{$item['quantity']}</td> <td>$".($item['unitprice'] * $item['quantity'])."</td></tr>"; $total += ($item['unitprice'] * $item['quantity']); } echo '</table>'; echo "<p><strong>Grand total: </strong>\$$total</p>"; } $message = "thanks for your patronage, please feel free to check back with us."; //create a mail function to send messages $email_message = "Message Date: ".date("F d, Y h:i a")." Name: ".$name." Email: ".$email." message: ".$message; #construct the email headers $to = $_GET['email']; $from = "shosoo1@yahoo.com"; $email_subject = "Efe shopping cart"; mail($to, $email_subject, $message, "From: ".$from); ?> <hr /> <p><a href="buyintocart.php">Go buy something</a></p> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.