Jump to content

how can I let user to add no of quantity they want display at the same time?


daredevil88

Recommended Posts

Hi all,

I am writing a shopping cart program. the flow is when customer select one product, it retrieves from database and show item description on screen and allow to enter the quantity customer want. so i wrote a funtion to retreive data from database and another funtion to display. in the display I would like to add an input so that user can add an quantity they want. but how can I pass the value of product_id and input quantity and how do I continue to manipulate the data.

if (is_array($product) ) {

 

        print "<table width=80% cellpadding=5>";

        print "<tr bgcolor='c6effy' align= center>\n";

        print "<td><b> Product Name </b></td>";

        print "<td><b> Unit Price  </b></td>";

        print "<td><b> Unit Quantity </b></td>";

        print "<td><b> Quantity to buy </b></td>";

      print "</tr>";

      print "<tr>\n";

        print "<td align='left'>$product[product_name]</td>";

        printf ("<td align='right'> $%0.2f </td>",$product[unit_price]);

        print "<td align='right'> $product[unit_quantity]</td>";

  print "<td align='center'><input type = 'text' name = 'quantity' value = '1' size = 2></td>";

print "</tr>";

print "</table>";

}

 

Can I send the value like a form? and please let me know how?

I know this has nothing to do with your question but get rid of all those print statements and wrap it all in one echo.  It will save you lots on script execution time not to mention readability.

Archived

This topic is now archived and is closed to further replies.

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