Ask Experts Questions for FREE Help!
  Advanced
Register  |  Log in  
   Ask    
 Answer  
  Help  

Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
Free Answers in 3 Easy Steps

Register Now
3 Steps

At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.

Home > Computers & Technology > Programming > Scripting > PHP   »   Create a shopping cart and a log book in php with mysql

 
Thread Tools Display Modes
Question
 
 
#1  
Old Jun 11, 2007, 04:33 AM
memory
New Member
memory is offline
 
Join Date: Feb 2006
Posts: 5
memory See this member's comment history on his/her Profile page.
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.

Reply With Quote
 
     

Answers
 
 
Old Aug 7, 2007, 06:27 AM   #2  
Senior Member
retsoksirhc is offline
 
retsoksirhc's Avatar
 
Join Date: Mar 2004
Location: Michigan
Posts: 741
retsoksirhc See this member's comment history on his/her Profile page.
Send a message via AIM to retsoksirhc
I prefer to use arrays to interact with a mysql database from PHP.

Once you have teh 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. Heres 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.
  Reply With Quote
 
     
 
 
Old Oct 31, 2007, 09:49 AM   #3  
Senior Member
vingogly is offline
 
vingogly's Avatar
 
Join Date: Oct 2007
Location: Naperville, Illinois
Posts: 613
vingogly See this member's comment history on his/her Profile page.
Call vingogly via Skype™
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
  Reply With Quote
 
     
 
 
Old Jan 4, 2008, 12:46 PM   #4  
Junior Member
interinfinity is offline
 
Join Date: Jan 2008
Location: Louisiana
Posts: 143
interinfinity See this member's comment history on his/her Profile page.
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
  Reply With Quote
 
     


Thread Tools
Display Modes

 
Similar Sponsors

Similar Threads
Question Asker Forum Answers Last Post
Connecting to MySQL with PHP on Apache 2.2 sypher373 PHP 2 Jan 11, 2008 02:48 PM
C++ and mysql Tsholofelo C++ 2 May 14, 2007 12:50 AM
MySQL with C++ Tsholofelo MySQL 0 May 10, 2007 03:15 AM
CommerceBuddy Shopping Cart Info Needed Tausha Internet & the Web 0 Sep 1, 2006 12:55 PM
Finding the right shopping cart jezter Internet Business 1 Nov 25, 2005 09:13 AM




Copyright ©2003 - 2007, Ask Me Help Desk.
All times are GMT -8. The time now is 11:47 AM.