Forum Moderators: coopster
$fname = fopen("phones.csv", "r") or die("Couldn't open file");
$line = fgets($fname);
list($num, $sum) = split(" ", $line, 2);
for($i=0; $i<$num; $i++){
if($number == $num){
echo "<br><br>The Cost of <strong>$number</strong> in <strong>$month</strong> was<br><br> <strong>€ $sum</strong>";}
else{echo "<br><br><br>Sorry the number was not found.";}
}
fclose($fname);
Where $number & $month is from the users query.
Any ideas thanks
fintan.
<?php
$fname= fopen("phones.csv", "r") or die("Couldn't open file");
while (!feof ($fname)) {
$line = fgets($fname, 4096); # row length up to 4KB
list($num, $sum) = split(" ", $line, 2);
if($number == $num) {
echo "<br><br>The Cost of <strong>$number</strong> in <strong>$month</strong> was<br><br> <strong>€ $sum</strong>";
} else {
echo "<br><br><br>Sorry the number was not found.";
}
}
fclose ($fname);
?>
[edited by: jatar_k at 4:56 pm (utc) on Aug. 22, 2003]
[edit reason] fixed sidescroll [/edit]
<?php
$fname= fopen("phones.csv", "r") or die("Couldn't open file");
while (!feof ($fname)) {
$line = fgets($fname, 4096); # row length up to 4KB
list($num, $sum) = split(" ", $line, 2);
if($number == $num) {
echo "<br><br>The Cost of <strong>$number</strong> in <strong>$month</strong> was<br><br> <strong>€ $sum</strong>";
break;
}
}
if ($number!= $num) echo "<br><br><br>Sorry the number was not found.";
fclose ($fname);
?>
[edited by: coopster at 4:30 pm (utc) on Aug. 22, 2003]
[edited by: jatar_k at 4:56 pm (utc) on Aug. 22, 2003]
[edit reason] fixed sidscroll [/edit]