what i am trying to do is put a order form on web it reads from database and puts up a list eg (dog biscuits 1kg) (£10.00) this is item and price but i wanted an extra empty columb for peeps to enter a number for qty when they have finshed they press submit and then the order gets emailed to me only the columbs with data in get sent <body> <form action="formtoemailpro.php" method="post"> <?php // Connects to your Database $dbh=mysql_connect("localhost", "xxxxxx", "xxxxx") or die('I cannot connect to database because: ' .mysql_error()) ; mysql_select_db("xxxxxxx"); //Retrieves data from MySQL $data = mysql_query("SELECT * FROM products ") or die(mysql_error()); Echo "<table border='1'> <tr> <th>ID</th> <th>Product</th> <th>Price</th> <th>Qty</th> </tr>"; while($info = mysql_fetch_array( $data )) { Echo "<tr>"; Echo "<td>" .$info['id'] . "</td>"; Echo "<td>" .$info['item'] . "</td>"; Echo "<td>" .$info['price'] . "</td>"; Echo "</tr>"; } Echo "</table>"; ?> </table> </form> PHP: this is what i have come up with so far but dosnt work not that that is a surprise here is the old way i did it <body> <form action="formtoemailpro.php" method="post"> <table width="768" border="0" cellspacing="5" style="background:#ececec"> <tr><td width="321"><strong>Price/Order List</strong></td> </tr> <th>Item</th> <th>Qty</th> <th>Item</th> <th>Qty</th> <tr><td><strong>Dogs Section</strong></td></tr> <tr><td>Dog biscuits 10kg £10.00</td><td><input name="dog biscuits 10 kg £10.00" type="text" value="" size="2" /></td></tr> <td>Bones 6 dose pack £21.50</td><td><input name="Bones 6 dose pack £21.50" type="text" value="" size="2" /></td></tr> <tr><td><strong>YOUR DETAILS</strong></td> </tr> <tr><td>Name: <span class="style1">required</span></td></tr> <td><input type="text" size="30" name="name"></td></tr> <tr><td>Email address: <span class="style1">required</span></td></tr> <td><input type="text" size="30" name="email"></td></tr> <tr><td>Tel: <span class="style1">required</span></td></tr> <td><input type="text" size="10" name="tel"></td></tr> <tr><td> </td></tr> <td><input type="submit" value="Send"><font face="arial" size="1"> </font></td></tr> </table> </form> </body> HTML: cheers Doug
You can use something like this. Please note this script does not do required security checks. You should add those before using it: It sends you the product name and qty ordered, and address of person placing order. Only those fields are emailed which are filled by person ordering. If the quantity is not filled that product will not be in order. <?php //connect to database if(isset($_POST[submit])){ $count= $_POST[count]; $m=''; for($x=1; $x<=$count; ++$x){ $a= 'a'.$x.'qty'; $b= 'a'.$x.'product'; if(is_numeric($_POST[$a])){ $m.= $_POST[$b]. ' - '. $_POST[$a]. '<br>'; } } $m.= $_POST[address]; mail('your@email.com', 'order here', $m); echo '<p> order placed </p>'; } $q= mysql_query(" select * from `products` "); $info= //get $q in an array for easier handling print ' <form action="" method="post"> <table><tr><td> Product </td><td> Price </td><td Qty </td></tr> '; $conunt=1; foreach($info as $v){ echo '<<tr><td>'. $info[product_name]. '</td><td>'. $info[price]. '</td><td> <input type="text" name="a'.$count.'qty" /> <input type="hidden" name="a'.$count.'product" value="'.$info[product_name].'" /> </td></tr>'; ++$count; } print ' </table><input type="hidden" name="c" value="'.$count.'" /> <p> Address: <input type="text" name="address" /></p> <input type="submit" name="submit" value="Order now" /> </form> '; ?> Code (markup): Thanks