Jump to content

Manipulating PHP/MySQL output


frank5050

Recommended Posts

Hi,

 

Given below is the output of a field from a mySQL/php query:

 

 

Product ID: 8457, Product Qty: 3, Product SKU: M-242, Product Name: DCE/DTE DB60 Crossover Cable - 1FT, Product Weight: 1, Product Variation Details: , Product Unit Price: 4.68, Product Total Price: 14.04|Product ID: 8800, Product Qty: 1, Product SKU: M-1038, Product Name: RJ45 8P8C Plug Flat Stranded 50pcs/Bag, Product Weight: 1, Product Variation Details: , Product Unit Price: 3.42, Product Total Price: 3.42|Product ID: 8940, Product Qty: 1, Product SKU: M-1385, Product Name: RJ11/12/45 Crimp Tool with Ratchet [HT-568R], Product Weight: 1, Product Variation Details: , Product Unit Price: 9.89, Product Total Price: 9.89

 

 

 

How can I add a <br> before every occurance of the term "Product" (without quotes).

 

That would make the output legible.

 

Should it be done client side, or server side.

 

I can use help for both.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/228741-manipulating-phpmysql-output/
Share on other sites

str_replace() would be much more efficient for a simple replacement such as this

$text = str_replace("Product", "<br />\nProduct", $text);

 

But why is all that text in a single database field. You should have each of those pieces of data in unique fields.

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.