Ask Experts Questions for FREE Help !
Ask
    memory's Avatar
    memory Posts: 5, Reputation: 2
    New Member
     
    #1

    Jun 11, 2007, 05:33 AM
    Create a shopping cart and a log book in php with mysql
    Please help!


    I am in a dilema. I have just started learning php; I am developing a website for an IT firm and I nid to add a shopping cart and a log book but I am not sure how. I have never done that in any other language, so am so blank. I can do the tables in mysql, but how do I link it with php?

    What I really need is at least a simple but working script/ code which I can understand.

    I will really appreciate.
    retsoksirhc's Avatar
    retsoksirhc Posts: 912, Reputation: 71
    Senior Member
     
    #2

    Aug 7, 2007, 07:27 AM
    I prefer to use arrays to interact with a mysql database from PHP.

    Once you have the tables created, you can do all the logging and editing from the php script


    <?php
    //First you need to connect
    mysql_connect("hostname","username","password");

    //Then, select the database you want to use
    mysql_select_db("mydatabasename");

    //Then the queries. Here's one to add
    mysql_query("INSERT INTO tablename ('fieldname1','fieldname2') VALUES ('value1','value2')");

    //Or you can gather information. This gets a bit tricky
    $query=mysql_query("SELECT * FROM tablename");
    while($row=mysql_fetch_row($mysql_query)){
    echo($row['fieldname1'] . " is the value of field1. The value of field2 is " . $row['fieldname2'] . "<br>");
    }
    ?>

    In that last part, we use the variable $query to store out query, and then we use the while loop to get each row that coem out of the query. This works because we use while($row=mysql_query($query)), and as long as there is more information we haven't seen yet in the query, it returns a value. Once we've gotten all the information, the mysql_fetch_row function will return FALSE, and the while loop will end. So, getting each row one at a time in a loop, we can do whatever we want with the data. Whatever the names of your fields are, you can use in the $row array.
    vingogly's Avatar
    vingogly Posts: 718, Reputation: 105
    Senior Member
     
    #3

    Oct 31, 2007, 10:49 AM
    There's a full-blown shopping cart example with all the code needed in PHP and MySQL Web Development. Don't recall if there's anything in there like a logbook, but if you can master the shopping cart I suspect the logbook will be a piece of cake. :-)

    Vasily
    interinfinity's Avatar
    interinfinity Posts: 142, Reputation: 8
    Junior Member
     
    #4

    Jan 4, 2008, 02:46 PM
    Go to barnes and noble. They have entire books full of ecommerce applications for php. I just recently bought 2 myself. Also Google search open source versions for php shopping carts, or entire ecommerce solutions. You can get a lot of ideas and tweak code to be custom for the site you are building

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Connecting to MySQL with PHP on Apache 2.2 [ 2 Answers ]

Hello all, Just a little background on my system. I am running Windows XP Pro SP2. Firewall is disabled. Running Apache 2.2, PHP5 and MySQL server 5.1. I am trying to simple interface with my MySQL database using a webpage running PHP. I have tried using the mysql_connect(host, name,...

C++ and mysql [ 2 Answers ]

I want a query that can select all names in a table and write it in sequential form in a listbox of a form in C++.the connection is well established and communication between my system and my datbase is working fine. here is the statement I used: requestName = SELECT SystemName FROM System;...

Finding the right shopping cart [ 1 Answers ]

I'm looking to buy/license an e-commerce system to sell a specialized product. This product requires the customer to put in from 3 to 12 detailed measurements, 4 other options. Once input the system will calculate a one-time price for this custom made item. I've been looking at a slew of shopping...


View more questions Search