Jump to content

[SOLVED] Php newbie help


baccarak

Recommended Posts

this will take most a few secs

I have a flat file Database which runs a text file

 

>>  Latest Special Offers|12TH-14TH JUNE 2009|per room, per night, Bed and Breakfast, minimum 2 night stay|79.00|CONTACT HOTEL DIRECT <<

 

and use

 

<link href="css/data.css" rel="stylesheet" type="text/css" />

<?php

$fp = fopen('data/offer.txt','r');

if (!$fp) {echo 'ERROR: Unable to open file.</body></html>'; exit;}

 

while (!feof($fp)) {

$line = fgets($fp, 500); //use 2048 if very long lines

list ($offer, $title, $description, $price, $details) = split ('\|', $line);

 

echo "<div class='offer'>$offer</div>";

echo "<div class='title'>$title</div>";

echo "<div class='desc'>$description</div>";

echo "<div class='price'>£$price</div>";

echo "<div class='details'>$details</div>";

 

$fp++;

}

 

fclose($fp);

 

?>

to display

the problem I have is that the text file adds a blank line after the last record and since I have to add a £ into code >> £$price  this echo's after the last record is displayed.

 

What to I have to add to omit showing the last line and the extra £ sign. I have got this far and tripped up on this, please help :)

Link to comment
https://forums.phpfreaks.com/topic/162149-solved-php-newbie-help/
Share on other sites

I have added

 

list ($offer, $title, $description, $price, $details) = split ('\|', $line);

trim($line, "\x0D\xa0\x09\x00");

but no joy

 

Latest Special Offers

12TH-14TH JUNE 2009

per room, per night, Bed and Breakfast, minimum 2 night stay

£79.00

CONTACT HOTEL DIRECT

£

 

thanks for replying CV :)

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.