How can I slash out a price to denote a sale price in html and php?
Well, the easiest way is to use the <strike> tag in html. This put a line through your text like so:
Code:
<strike>$9,999</strike>
Result:
$9,999
For a more complex solution, you can use PHP to create an image, on the fly, putting a red slash across your prices. Here's a solution:
<?php
header("Content-type: image/png");
$string = $_GET['n'];
$string = "$".number_format($string);
$im = imagecreatefrompng("blank.png");
$black = imagecolorallocate($im, 0, 0, 0);
$red = imagecolorallocate($im, 196, 0, 0);
imagestring($im,5, 0, 0, $string, $black);
$points = array(0,11,1,13,54,6,55,4);
imagefilledpolygon($im,$points,4,$red);
imagepng($im);
imagepng($im,"./".$_GET['n'].".png");
imagedestroy($im);
?>
Note a few things:
- This script gets called like so: script.php?n=8888, where n is the price you wish to display.
- You need a blank (white, or whatever color your background is) image - called blank.png in the same directory as the php script.
- The data points in the "array" line probably need tweaking, depending how big your image is. Do some testing, see what works.