Niksou Posted July 21, 2020 Share Posted July 21, 2020 (edited) Hello, I'm a cs student (2nd year) this year has been a disaster for us the students(studying over zoom and shit), I have a tiny tiny project that a have to finish in the next 24 hours, we made a small sample website using html and js, and now we need to switch it to php language and make the site responsive and later on add SQL. I would very much appreciate if someone can help me for couple of minutes over zoom and help me complete it. All I have left is echo the products from an array with a loop and make a php table that will put my items to my cart. It's my first time here..hope there is some good people here Edited July 21, 2020 by requinix added thread title Quote Link to comment Share on other sites More sharing options...
requinix Posted July 21, 2020 Share Posted July 21, 2020 This is a forum for posting problems and getting answers. It's not good for soliciting individual and personalized help from a single person. You're much more likely to get help by posting your code and asking specific questions instead of hoping someone will come along and decide that they want to do a video chat with a complete stranger. Ready to do that? If all you have left is this thing with a loop and table then this should be pretty quick and easy. 1 Quote Link to comment Share on other sites More sharing options...
Niksou Posted July 21, 2020 Author Share Posted July 21, 2020 Ok sounds good my friend so here is an example for one item from my store ' all the other items are alike, also here is my array the I want to use in order to echo the items in my store , I just noticed that i said table but i meant form, what I need to do is make a form in a sepperate php file that will have only quantity of each item and later on will send it to my shopping cart with post request. sorry for my bad english , I can explain myself better if needed. in the last picture is my website i need to change the add to cart button to quantity and in the bottom of the page add button purchase that will send me to my cart with the items selected. Quote Link to comment Share on other sites More sharing options...
Niksou Posted July 21, 2020 Author Share Posted July 21, 2020 Trying this to print the items but no help Quote Link to comment Share on other sites More sharing options...
Niksou Posted July 21, 2020 Author Share Posted July 21, 2020 Update: done with the echo in loop..now only the form thingy and that's it!! Quote Link to comment Share on other sites More sharing options...
kicken Posted July 21, 2020 Share Posted July 21, 2020 @Niksou, when you're posting code, do so as text not images. Copy your code then use the Code button (<>) in the editor to create a code block and paste your code there. If you don't post it as text, nobody can copy it to a file and test it in order to help you, so they will likely just skip your thread and you'll get no help at all. If you want to change your Add to Cart button to a quantity input then change the <button> tag to an <input> tag of type number. Add your new add to cart button where you want it. After that you'll have to figure out how to update the code that handles your cart to work with the new design. If you have a specific problem you are stuck on then post about it, but a post like "I want to do <some generic thing>" followed by a bunch of code is generally not well received. 1 Quote Link to comment Share on other sites More sharing options...
requinix Posted July 21, 2020 Share Posted July 21, 2020 The first thing I would have to see is the code (in text form) of displayCart. What does the 0 mean? Can it add products to the cart? Another thing is the PHP script you have for adding products to the cart. Is that ready to use? What POST data do you need to send? A simple change to make now would be to add the quantity input next to the button. For how many to add to the cart. 1 Quote Link to comment Share on other sites More sharing options...
Niksou Posted July 22, 2020 Author Share Posted July 22, 2020 hello , sorry for my inexperience in forums, any way here is my git will all the code , https://github.com/niksou/Web-site display cart 0 means that i add the item (id=0) to cart using js, the post data i need to send is product name price and quantity to to cart page which will be a seperate page that displays all added to cart items withtheir amount and their total price. im not sure where or how to place the form that will add the items to my cart using post method. in general , just send the items from my cart to the cart.php page Quote Link to comment Share on other sites More sharing options...
Barand Posted July 22, 2020 Share Posted July 22, 2020 All you should be sending to the cart is product id and quantity. Never allow the user the specify their own price, otherwise you'll end up selling everything for 0.01. On the cart page, query the database to get price and description. Quote Link to comment Share on other sites More sharing options...
Niksou Posted July 22, 2020 Author Share Posted July 22, 2020 this is not supposed to be secured web-site , only small project that i have. will be gratfull if you show me how to. Quote Link to comment Share on other sites More sharing options...
Niksou Posted July 22, 2020 Author Share Posted July 22, 2020 also in the header part I have this function :written in js function updateSum(price) { $('#sum').innerText = parseInt($('#sum').innerText) + price } that supposed to update the sum here in header part : Total:<span id="sum"></span>$ but for some reason nothing changes Quote Link to comment Share on other sites More sharing options...
kicken Posted July 22, 2020 Share Posted July 22, 2020 $('#sum').innerText That syntax mixes jQuery and plain Javascript which you cannot do. $('#sum') creates a jQuery object, but .innerText is a DOM property in plain javascript. The jQuery way to read/set the text value of an element is with the .text() method. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.