Database based order form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Deccypher
    New Member
    • Mar 2008
    • 14

    Database based order form

    Hi I am trying to give my customers an option to save favorite products for easy storage and reorderig.

    it works great and on the single item add to cart i have no problem, how ever i would also like to give them the option to virew all their fav's in an order form like format with a single add to cart button. the problem is that as its pulled from the database the inputs it generates are all called the same so it only add the very last item to the cart.

    im looking for some advise on how to do this rather than actual code. should i put a counter on and increase the input name by 1 with each row, or use the tabel row id as the name. if using them then how would i catch all the inputs on the next page when typically there could be upto 1800 entries in their fav list

    heres the current code im using

    [PHP]session_start() ;
    $account=$_SESS ION['account'];
    $user=$_SESSION['username'];
    echo"<form id=\"form1\" name=\"form1\" method=\"post\" action=\"cart.p hp?mid=4\">

    <table>
    <tr>
    <td>&nbsp;</td>
    <td>Part number</td>
    <td>Quantity</td>
    </tr>";
    include 'pathtoconfig/config.php';
    include 'pathtoopendb/opendb.php';

    $sql2 = "SELECT * FROM `fav` WHERE `account`=\"$ac count\" AND `user` =\"$user\" ";
    $result2 = mysql_query($sq l2) or die('Query failed. ' . mysql_error());
    while($_row = mysql_fetch_arr ay($result2))
    {
    $id=$_row["id"];
    $account=$_row["account"];
    $user=$_row["user"];
    $qty=$_row["qty"];
    $ptno =$_row["ptno"];

    include "pathtopric ing/pricing.php"; //$price is pulled from this file




    echo" <tr>
    <td><br>
    <img src='/images/products/$ptno.jpg' /></td>
    <td><b>$ptno</b>
    <input name=\"ptno\" type=\"hidden\" id=\"ptno\" value=\"$ptno\" />
    <input name=\"account\ " type=\"hidden\" value=\"$accoun t\" />
    <input name=\"price\" type=\"hidden\" value=\"$price\ " /></td>
    <td><input name=\"qty\" type=\"text\" class=\"inputbg \" id=\"textfield\ " size=\"7\" value=\"$qty\"/></td>
    </tr>";
    }

    echo"<tr>
    <td colspan=\"2\">A djust quantities on above items and click submit<br>(to not include an item set quantity to zero)</td>

    <td><input DISABLED type=\"submit\" name=\"submit3\ " value=\"Add to Cart\" class=\"submit_ search\" /></td>
    </tr></tabel></form><br>";


    }

    [/PHP]


    so im really not sure where to go with this..

    any help or ideas would be greatly received
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    When you want to distinguish between all different products you 'll have to use different names (and certainly different id's).

    Increment a counter in the while loop and append that counter to the name field.

    Ronald

    Comment

    Working...