Jump to content

Recommended Posts

Hi Chaps,

I have a site which calls in products from a database and displays them on a page. What I've now done is to create a hyperlink from the product code of each product to an order form, so effectively you can add an item to the order form. So far so good with this. The hyperlink takes the values '$item_number' and '$product_name' into the PHP order form.

Up to now this works perfectly but people can only add one item to the order form. How can I make sure that my order form adds a new row and the relevant boxes each time someone updates their order by clicking on another item?

Here's the code of the order form (I only have one row currently in the table that displays the products):

[code]
<?php

print("
<form name=\"form1\" method=\"post\">
<input type=\"hidden\" name=\"action\" value=\"addscript\" size=\"20\">
<table width='580' border='1' cellpadding='2' cellspacing='0' bordercolor='#000000'>
  <tr valign='top'>
    <td width='70%'><div align='center'><font size='2'><strong>Product Description</strong></font></div>
    </td>
    <td width='15%'><div align='center'><font size='2'><strong>Product Code</strong></font></div></td>
    <td width='15%'><div align='center'><font size='2'><strong>Quantity</strong></font></div></td>
  </tr>
  <tr>
    <td width='70%'><input name='desc11' type='text' id='desc11' value='$product_name' size='45'></td>
    <td width='15%'><div align='center'>
      <input name='code11' type='text' id='code11' value='$item_number' size='20'>
    </div></td>
    <td width='15%'><div align='center'>
      <input name='qty11' type='text' id='qty11' size='5'>
    </div></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td><div align='center'>
      <input type='submit' name='Submit' value='Submit Order'>
    </div></td>
    <td><div align='center'>
      <input type='reset' name='Submit2' value='Reset'>
    </div></td>
  </tr>
</table>
</form>
");

?>[/code]

Any know how best I can achieve this?

Thanks
Link to comment
https://forums.phpfreaks.com/topic/24355-php-order-form/
Share on other sites

What you want is a shopping cart.

You need to keep track of a number of selections and assocciate them with a session_id/ip_address/username (if applicable).
Then when they "check-out" the shopping cart you can create a dynamic form with all the items from their shopping cart.

Have a look at these links for some ideas:
[url=http://php.resourceindex.com/Complete_Scripts/Shopping_Carts/]http://php.resourceindex.com/Complete_Scripts/Shopping_Carts/[/url]
[url=http://www.shop-script.com/]http://www.shop-script.com/[/url]
Link to comment
https://forums.phpfreaks.com/topic/24355-php-order-form/#findComment-111119
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.