esoteric Posted July 22, 2011 Share Posted July 22, 2011 Hi again, so far everyone been a huge help but once again i'm in need of you expertise So when a customer checks out, after filling in an order form its processed through a script called 'checkout_process.php' here is a snippet of the part that shows what was in the cart $strMessageBody = "$REMOTE_ADDR\n"; $strMessageBody .= "Order Date : $today \n"; $strMessageBody .= "Your Order Number #"; $strMessageBody .= "$order \n"; $strMessageBody .= "We have received your order for processing.\n"; $strMessageBody .= "Bill To: \n"; $strMessageBody .= "-------- \n"; $strMessageBody .= " $b_first $b_last \n"; $strMessageBody .= " $b_addr \n"; $strMessageBody .= " $b_addr2 \n"; $strMessageBody .= " $b_city, $b_zip \n"; $strMessageBody .= " $b_phone \n"; $strMessageBody .= " $b_fax \n"; $strMessageBody .= " $b_email \n"; $strMessageBody .= " \n"; $strMessageBody .= " \n"; $strMessageBody .= "Qty Price(\£) Product ID - Product Name\n"; $strMessageBody .= "===================================================================== \n"; $strMessageBody .= "$QUANTITY_1 \$$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n"; if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2 \$$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";} if( $NAME_3 ) {$strMessageBody .= "$QUANTITY_3 \$$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";} if( $NAME_4 ) {$strMessageBody .= "$QUANTITY_4 \$$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";} if( $NAME_5 ) {$strMessageBody .= "$QUANTITY_5 \$$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";} if( $NAME_6 ) {$strMessageBody .= "$QUANTITY_6 \$$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";} if( $NAME_7 ) {$strMessageBody .= "$QUANTITY_7 \$$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";} if( $NAME_8 ) {$strMessageBody .= "$QUANTITY_8 \$$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";} if( $NAME_9 ) {$strMessageBody .= "$QUANTITY_9 \$$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";} if( $NAME_10 ){$strMessageBody .= "$QUANTITY_10 \$$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";} if( $NAME_11 ){$strMessageBody .= "$QUANTITY_11 \$$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";} if( $NAME_12 ){$strMessageBody .= "$QUANTITY_12 \$$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";} if( $NAME_13 ){$strMessageBody .= "$QUANTITY_13 \$$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";} $strMessageBody .= "===================================================================== \n"; $strMessageBody .= "TOTAL: $TOTAL \n"; $strMessageBody .= "\n"; $strMessageBody .= "Comments: \n"; $strMessageBody .= "--------- \n"; $strMessageBody .= "$comment \n"; $strMessageBody .= " \n"; $strMessageBody .= "Please contact us at $youremail. If you have any questions or concerns, please reference your OrderID# $order."; I have a page on my site which is showing all orders new and old, i want to display the items purchased on it but what i have done seems very messy and doesn't really display as i want it, for example, empty values are shown as a 0 Here is the table im using to display the info so you can see what im trying to achieve <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><?php $sql="SELECT * FROM orderTable WHERE userId = '{$_SESSION['user_id']}'"; if ($query=@mysql_query($sql)) { if (mysql_num_rows($query) > 0) { while ($req=mysql_fetch_array($query)) { ?></td> <td width="502"> </td> </tr> <tr> <td class="description">Order Number:</td> <td><input name="textfield" type="text" disabled id="textfield" value="<?php echo $req['orderNum'];?>"></td> </tr> <tr> <td class="description">Date:</td> <td><input name="textfield" type="text" disabled id="textfield" value="<?php echo $req['orderDate'];?>"></td> </tr> <tr> <td class="description">Invoice Total:</td> <td><input name="textfield" type="text" disabled id="textfield" value="<?php echo $req['total'];?>">*does not include delivery or discounts</td> </tr> <tr> <td class="description">Product(s)</td> <td><textarea name="textarea3" cols="45" rows="3" disabled id="textarea3"> <?php echo $req['quantityOne'];?> <?php echo $req['nameOne'];?> <?php echo $req['quantityTwo'];?> <?php echo $req['nameTwo'];?> <?php echo $req['quantityThree'];?> <?php echo $req['nameThree'];?> <?php echo $req['quantityFour'];?> <?php echo $req['nameFour'];?> <?php echo $req['quantityFive'];?> <?php echo $req['nameFive'];?> <?php echo $req['quantitySix'];?> <?php echo $req['nameSix'];?> <?php echo $req['quantitySeven'];?> <?php echo $req['nameSeven'];?> <?php echo $req['quantityEight'];?> <?php echo $req['nameEight'];?> <?php echo $req['quantityNine'];?> <?php echo $req['nameNine'];?> <?php echo $req['quantityTen'];?> <?php echo $req['nameTen'];?> <?php echo $req['quantityEleven'];?> <?php echo $req['nameEleven'];?> <?php echo $req['quantityTwelve'];?> <?php echo $req['nameTwelve'];?> <?php echo $req['quantityThirteen'];?> <?php echo $req['nameThirteen'];?> </textarea></td> </tr> <tr> <td width="122" class="description">Name:</td> <td><input name="textfield" type="text" disabled id="textfield" value="<?php echo $req['lastName'];?>, <?php echo $req['firstName'];?>"></td> </tr> <tr> <td class="description">Address:</td> <td><textarea name="textarea2" cols="45" rows="3" disabled id="textarea2"><?php echo $req['address1'];?>, <?php echo $req['address2'];?> <?php echo $req['city'];?>, <?php echo $req['postCode'];?> </textarea></td> </tr> <tr> <td class="description">Contact:</td> <td>Tel: <input name="textfield" type="text" disabled id="textfield" value="<?php echo $req['phone'];?>"> Fax:<input name="textfield" type="text" disabled id="textfield" value="<?php echo $req['fax'];?>"></td> </tr> <tr> <td class="description">Additional Information</td> <td><textarea name="textarea" cols="45" rows="4" disabled id="textarea"><?php echo $req['comment'];?></textarea></td> </tr> <tr> <td colspan="2" class="description"><?php } } else { echo "No orders found."; } } else { echo "Query failed ".mysql_error(); } ?></td> </tr> </table> as you can see the product bit is super messy and i doesn't display right, it also means i have 13 lines in my table for quantity and another 13 for the name, doesn anyone have an idea an how to tidy this up? Quote Link to comment https://forums.phpfreaks.com/topic/242668-echo-products/ Share on other sites More sharing options...
phpSensei Posted July 25, 2011 Share Posted July 25, 2011 I saw your post has 0 reply and the reason is either it was lost and no one saw it, or its that your asking us to tidy up your code.. Quote Link to comment https://forums.phpfreaks.com/topic/242668-echo-products/#findComment-1246500 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.