Jump to content

PHP Commerce Help


bluestreak101

Recommended Posts

Hi all,

 

I'm a bit of a newbie to this type of website and would be extremely grateful for any help on this as it's causing considerable headaches!  :(

 

I've been working on an e-commerce (Online Shop) website based on the site found here: http://www.phpwebcommerce.com/

 

I have been building it into a template from the original shop that was essentially a static website with links to paypal for the cart etc.

 

Now I am trying to add an extra function to the site but cant get my head around the logic to making this work and I know it can be done!

 

The shop is to sell mainly shoes with some accessories. So I understand that shoes obviously come in a variety of sizes, and each size needs to have its own product ID in the MySQL DB so I can show whether it is in stock etc.

 

What I cant figure out is how to firstly make an easy way of adding the shoes different sizes (for eg 10 shoes of the same type in sizes 40-49) to the DB in one hit instead of filling in the same form 10 times but with different sizes. I have the simple form already made and working successfully. My thoughts are to add check box in the form to say I'm adding multiple shoes that tells the process to look for values in text areas for starting shoe size and last shoe size. The process then takes the start size from the end size giving the number of times to loop the process. It then loops the process for each size using the same information... Logically this works but I'm not sure how to code this on what I have. I have attached the files used directly in this.

 

Secondly how do I group the shoes on the front end.

 

Now each product on the front end currently will display a simple message instead of add to cart when the stock = 0, or the product has been made as available on request.

 

I would like to group the shoes of the same type to have a drop down menu showing the available sizes. When a size is selected it needs to query the DB for available stock and either show the 'Add to cart' or 'Call to order' options.

 

Anything else you might need to help with this let me know. I'm keen to get this bit done so I can get the site live!

 

Thanks in advance

18089_.php

18090_.php

Link to comment
Share on other sites

I'm not going to go modify your code, but here's a simple example of how this might be done.

<?php 
if (isset($_POST['NewShoe'])){
$insert="";
$sizefrom=trim($_POST['sizefrom']);
$sizeto=trim($_POST['sizeto']);
$size=$sizefrom;
$newshoe=mysql_real_escape_string(trim($_POST['shoename']));
if (!empty($sizeto) && $sizeto>$sizefrom){
WHILE($size<=$sizeto){
$insert.="('$newshoe','$size')";
$insert.=($size<$sizeto ? ',' : '');
$size++;
}
}else{
$insert.="('$newshoe','$size')";
}
$sql="INSERT INTO `shoetable` (shoename, shoesize) VALUES $insert";
mysql_query($sql) or trigger_error($sql . ' has encountered and error<br />' . mysql_error());
}

?>
<html>
<head>
<style type="text/css">
.width70{
width:70px;
}
</style>
<body>
<form action="" method="post">
Shoe Name: <input type="text" name="shoename" /><br />
Size: <input type="text" name="sizefrom" class="width70" /> To: <input type="text" name="sizeto" class="width70" /><br />
<input type="submit" name="NewShoe" value="Add New Shoe" />
</form>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.