Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flatfile reading?

Status
Not open for further replies.

wazza

Vendor
Aug 28, 2000
3
CA
I need to know how open a flatfile for reading and submitting in a html form.

heres how the flat file looks.
$field1|$field2|$field3|$field4|

I need to be able to open that file while grabbing only 10 results at a time.

Any ideas?
 
I use a small technique collect all the values from the flat file in a array.display the first 10 values.

$r is the starting point.
$results=10(10 sets of result)

$x=$r+$results;
ie) for($i=$r;$i<$x;$i++)
{
print $filearray[$i];
}
to get the next set of results pass the starting point in $r


Thus u can display 10 set of results from a flat file.

I hope u got the logic....
 
Hello,

Ok ive been able to get the code working. Although i have run in to a problem. If any one can take a look and maybe let me know what im doing wrong that`d be great. Problem is that i have the results printing to the page in lots of 5... but each result is the same. Last line in the data file.

Any ways heres the url
and the code below.

Thanks guys,
wazza
--------start---------
@results = ($invoiceno,$contactname,$contactemail,$company,$address,$state,$city,$zipcode,$country,$title,$description,$category,$emailcategory,$password,$url,$recipurl,$signupurl,$date);
$number_of_sites = @results;
$result_count = $number_of_sites;
$pgsz = 5;

if ($result_count != 0) {
$pagecount = int($result_count / $pgsz);
if (($pagecount * $pgsz) != $result_count) {
$pagecount++;
}
}

if (!$A::rqpg) {
$rqpg = 1;
}
else {
$rqpg = $A::rqpg;
}

$firstresult = (($rqpg - 1) * $pgsz) + 1;
$lastresult = $firstresult + $pgsz - 1;
if ($lastresult > $result_count) {
$lastresult = $result_count;
}
$prev_page = $rqpg - 1;
$next_page = $rqpg + 1;
if ($rqpg == 1) {
$prev_link =
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top