note 80511 deleted from function.file by felipe
| From: | felipe@php.net | Date: | Wed, 23 Jan 2008 21:53:52 +0000 |
| Subject: | note 80511 deleted from function.file by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135351@lists.php.net to get a copy of this message | ||
Note Submitter: SID TRIVEDI
----
<?php
/****************************************
* TITLE : SIMPLE PRODUCT 'n' PRICE DISPLAY USING .txt FILE without any
My_SQL, PostgreSQL or Oracle Database.
* @ Notes : It's very easy to configure
*********************************************/
/*
CONFIGURE FOLLOWING OPTIONS AND SNIPPET WILL START WORKING.
1) Make a display.txt file containing product i.d (starting from 001),
Product Description, Product Value (you can define local currency)
seperated by , comma. New product-->New line.
001,IBM DESK-TOP PC...blah blah...blah, 899.99
002,SONY NOTE-BOOK....blah blah...blah, 999.99
2) Configure options as stated below.
3) Save file as products.php
*/
//absolute path to display.txt
$fh = 'http://www.myweb.com/display.txt';
//absolute path to image directory
// image 001.jpg coresponds to product id # 001
$image_dir = 'http://www.myweb.com/images/';
// all product images are of same size and same type (.jpg)
// Try to maintain uniformity, all images should be same size and same type.
$prod_image_type = '.jpg'; // .jpg , .gif or .png
//define your local currrency type
$cur = 'U$';
//---PLEASE DO NOT MODIFY ANY THING BELOW.
// UNLESS YOU KNOW WHAT YOU ARE DOING !!!
$handle = fopen($fh, "r");
$read = file ($fh);
$count = count($read)- 1;
echo "<TABLE
BORDER="."\"1\""."bordercolor="."\#111111".
"width="."\"800\"".">";
echo "<TR><TH>Product ID</TH><TH>Image</TH>
<TH>Product Description</TH>
<TH>Value in USD</TH></TH>";
for ($i=0; $i <= $count; $i++){
list($id, $item, $value) = explode('|', $read[$i],3);
$image = $id.$prod_image_type;
$image_src = $image_dir.$image;
echo "<TR><TD width="."\"05%\"".">".$id.
"<TD width="."\"AUTO\"".">".
"<p align="."\"center\"".">".
"<img border="."\"0\""." src=".$image_src."
width=".
"\"50\""."
height="."\"50\""."></TD><TD
width="."\"85%"".">".$item."</TD><TD
width=".
"\"15%\""."><b>".$cur.$value."</b></TD></TR>";
}
echo "</TABLE>";
fclose($handle);
?>