Also I do happen to like how a customers list is displayed when you click on the + plus symbol along side a customers order. So I am going to send a version of this over to an email that I normally send out to customers and include product images.

However, and reason for this posting; I was to discover the data ‘constructed’ in the background was giving me a genuine head ache and perhaps evidence of the mix and match approach used by ISC when writing their cart.
To explain. The example image section shown above is incomplete (as you may note), but this has much of its information taken from the mySQL table isc_order_products
The data held here otherwise alphanumeric and clear text readable. If it says (by example) “Black Grecian Maxi Dress” and if it says ‘1356/Cobolt’, then you can be sure it reads exactly as written.
However, take a read of the data held that mentions ‘Colour’. We have (by example) Colour: Colbolt or (say) Colour Black-White. What you get in mySQL in table isc_order_products under column ordprodoptions is not just text, it’s more..

So to get from this –


I tried a number of variations of this and no doubt missed the best solution. The variation I used is based on the following -
Code: Select all
<?php
$user_name = "xxxx"; // Change all XXX's to match your requirements
$password = "xxxxxx";
$database = "xxxxxxxxxx";
$server = "xxxxxxxxxx";
$db_handle = mysql_connect($server, $user_name, $password);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
$result = mysql_query("SELECT isc_order_products.ordprodname
, isc_order_products.ordprodsku
, isc_order_products.ordprodoptions
FROM
xxxxxxxxxx.isc_order_products"); // I have stayed inside one table for this example
function clean_string($string) {
$string = preg_replace('/[^a-z\\040\\.\\-\/]/i', ' ', $string); // Filter non alphanumeric
$string = preg_replace('/\b\w\b(\s|.\s)?/', '', $string); // Filter any single letter
return $string;
}
while ($row = mysql_fetch_assoc($result)) {
$string = $row['ordprodoptions']; // Pass SQL data for local use
$str = clean_string($string); // Run clean up of data string
echo "<table border='0' width='70%'><tr> // Display findings from table
<td>". $row['ordprodname'] ."</td>
</tr>
<tr>
<td>". $row['ordprodsku'] ."</td>
</tr>
<tr>
<td>". $row['ordprodoptions'] ."</td> // Output of un-cleaned data string
</tr>
<tr>
<td>". $str ."</td> // Output of cleaned data string
</tr>
</table>"; }
}
mysql_close($db_handle);
?>

The key script elements from above -
function clean_string($string) {
$string = preg_replace('/[^a-z\\040\\.\\-\/]/i', ' ', $string); // Filter non alphanumeric
$string = preg_replace('/\b\w\b(\s|.\s)?/', '', $string); // Filter any single letter
return $string;
}
$string = $row['ordprodoptions']; // Pass SQL data for local use
$str = clean_string($string); // Run clean up of data string
*** Note - Once running my test code, you might find the 'clean' seems to have failed on a number of occasions. Not so.. That would be a sale that may have been dropped and so nolonger contains the active value of '1' in its makeup (a:1: active while a:0: inactive) . ISC does not house keep dead data and easy enough to filter.