Hey there guys.
I need some ideas on how I'm going to be designing this.
Here's a brief info about what this website is going to be and do. It's a order-pizza-online website where users can click on their favourite pizza, choose toppings, size etc and be able to either use the action: "add to cart" or "proceed to checkout".
Also, once pizza is added to cart, the user is automatically taken back to the main menu to choose another, either a side or another pizza etc.. and then after they have completed their order, they can "proceed to checkout".
The thing is, i was wondering if its possible for them to add cart and then go around shopping for more etc... I can do it for a straight forward order from one page.. but with another extra action, maybe a bit too intense for me to figure out.
Thanks!! please help a buddy out ;>
Just add their order to a session. It will track along with them 
Yeah, was thinking about that... the only bitch is to attach a price tag on them. Should I be using arrays?
oh and one other thing.. I was wondering how to past an email with the syntaxes such as @ through a mySQL database? lol.. I'm using varchar atm, but so totally lost on what type to use.
help!
The way I would do it is to save as an array like you've just mentioned. Store as item_id and then quantity. ie
| Code: |
$_SESSION['cart_items']
array(3) {
[0] => // item 1
array(2) {
[0]=>
int(1) // item_id
[1]=>
int(2) // quantity
}
[1] => // item 2
array(2) {
[0]=>
int(2) // item_id
[1]=>
int(1) // quantity
}
[2] => // item 3
array(2) {
[0]=>
int(36) // item_id
[1]=>
int(3) // quantity
}
} |
Using this, I would query the price from the database.
| Quote: |
| oh and one other thing.. I was wondering how to past an email with the syntaxes such as @ through a mySQL database? lol.. I'm using varchar atm, but so totally lost on what type to use. |
That doesn't work? varchar works fine for me 
yeah...
well heres the link:
http://www.clydejaw.frih.net/test.html
-_-''
Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '@hotmail.com)' at line 3
Its working fine for me :s
I get a message telling me I will be sent a confirmation email.
are there any special chars in the email you tried / did you mysql_real_escape it?
hahaha, that was a dummy website and I'm not quite sure if the email really did send.
If it did then i'm quite impressed by the little amount of code you have to write haha.
So far, I thought I could include 2 buttons with 2 actions but apparently not, so i've decided to change the concept and have only "Add" then a redirect back to the main menu.
[url]
www.clydejaw.frih.net/main.php[/url] <--- this is what I have so far
The assignments due 2moro -_-'' bwahahah, all I gotta do now is set up an array which is going to be a biatch
!
How do you think phpbb's post and preview work if there aren't two buttons with different actions?
button 1s name is add
button 2s name is order
| Code: |
session_start();
//Do database queries etc.
if(isset($_POST['add'])){
//Add selection to session
//Using mathias's code
}
if(isset($_POST['order']))
//ad order to database
}
|
okay i've sorted that out. I'm just setting up the database now, however:
CREATE TABLE orders (
id int(6) unsigned NOT NULL auto_increment,
ptype varchar(100) NOT NULL default '',
psize varchar(100) NOT NULL default '',
pbase varchar(100) NOT NULL default '',
price decimal(3,2) NOT NULL default '0.00',
PRIMARY KEY (id)
) TYPE=MyISAM;
I created this in my database, and when i want to add values such as:
INSERT INTO books VALUES (001, 'Meat','Small','Pan','8.50');
i get an error syntax for adding these values. I tried adding without the ID aswell, but yeah. Won't say where I've made any errors.. perhaps someone can help a noob out?
INSERT INTO orders(column1, column2) VALUES (001, 'Meat','Small','Pan','8.50');
| Manofgames wrote: |
| INSERT INTO orders(column1, column2) VALUES (001, 'Meat','Small','Pan','8.50'); |
Not necessary, and anyway, in this case it would have to be:
INSERT INTO orders(id, ptype, psize, pbase, price) VALUES...
No, I saw two things wrong with the query posted. One was that you're inserting into a table called "books" rather than "orders". The other is that id probably shouldn't have trailing 0s. This is how I'd have the query:
INSERT INTO orders VALUES ('', 'Meat', 'Small', 'Pan', '8.50');
The '' for id will be filled in automatically by the auto_increment set on id. Alternatively, you could use this:
INSERT INTO orders(ptype, psize, pbase, price) VALUES ('Meat', 'Small', 'Pan', '8.50');
sorry, i copied the books one by accident. I had actually used
INSERT INTO orders VALUES (00001, 'Meat', 'Small', 'Pan', '8.50');
but now that u mentioned about auto increment, that means I don't really need to include the ID? ill try it out.
INSERT INTO order VALUES ('', 'Meat', 'Small', 'Pan', '8.50');
okay I had used that, but i get an error syntax.. aswell as the one i tried below aswell:
INSERT INTO order (ptype,psize,pbase,pprice) VALUES ('Meat', 'Small', 'Pan', '8.50');
IT JUST KEEPS GIVING ME SYNTAX ERRORS
!
EDIT: altho perhaps the last variable (pprice) is a decimal. So do i need to single-quote it?