Jump to content

In Need Of Help Badly! Open .dat file and using the variables in it.


hockeyman10

Recommended Posts

Hello Everyone. I posted this elsewhere but can't seem to get any help so I thought i'd try this site out.

 

What I am trying to do is load in a .dat file that has thousands of lines of code. each line is divided like...

 

username|first_name|Last_name|ad_title etc...

 

I have a code in Perl that I can use this information in variables. I need to do it in PHP and I have no idea what I am doing. Here is what I know needs to happen. This code is just showing what needs to be done and I can't get anything to work with it..

 

<?php 

$data_file="data.txt";



open file
while (not EOF)
  




list($ad_number,$user_name,$user_type,$date,$var_1,$var_2,$var_3,$var_4,$var_5,$var_6,$var_7,$name,$var_8,$city,$province,$postal_code,$country,$phone_num ber,$var_9,$email,$var_10,$category,$subcategory,$caption_header,$caption,$ad_text,$price,$var_11,$var_12,$var_13,$var_14,$var_15,$var_16,$private,$va r_17)= explode("|", $data); 








if ($city == "Toronto") {
print "<table width=100%><tr><td>$city</td><td> $username</td></tr></table>";
}


end while
close file




?>




 

 

Now I don't even know where to start with this. I keep reading these tutorials and just cannot find what I actually need to do and I am losing hope with this code. If anyone has any free time and would like to give a hand. I'd be very thankfull! Please let me know. thank you for your time.

 

1)

What I am trying to do is load in a .dat file that has thousands of lines of code. each line is divided like...

2) Just don't come here for a once off purpose, there is such a thing as time. Wait at the other site dont just go sign up at this site to get 1 little thing.

2) We dont write the scripts for You!

 

btw Google!

I'm sorry. I just meant it as... I'm going to need a site for help and that while I get this completely down like all other things I have worked with... the Other site is obviously not doing it for me. been waiting a while. I'm sorry I didn't mean to come off sounding like I just need help with this and I'm gone. This site really seems to have a good community feeling that I'd like to be a part of.

Thankl you very much!!!

 

Is there any way that I could read from the bottom of the file - up. The latest entries are placed at the bottom of the data file. I need a way to display them in that order. does anyone know what I can do here?

Here is my code. I tried that out and I don't think it is what I am looking for. Maybe I am going about this totaly wrong...

 

### Display Ads



$handle = @fopen("/usr/home/sellitbu/public_html/www.sellitbuyit.ca/cgi-bin/classifieds/data/ads.data", "r");


$row = 3;
$x = 1;



    while (!feof($handle)) {




$buffer = fgets($handle, 4096);







list($ad_number, $user_name, $user_type, $date, $var_1, $var_2, $var_3, $var_4, $var_5, $var_6, $var_7, $name, 

$var_8, $city, $province, $postal_code, $country, $phone_number, $var_9, $email, $var_10, $category, 

$subcategory, $caption_header, $caption, $ad_text, $price, $var_11, $var_12, $var_13, $var_14, $var_15, 

$var_16, $private, $var_17) = explode("|", $buffer);





if ($count == "10") {

} else {
if ($city == "Toronto")  {
if (($date == "$last_0_final") || ($date == "$last_1_final") || ($date == "$last_2_final") || ($date == "$last_3_final") || 

($date == "$last_4_final") || ($date == "$last_5_final") || ($date == "$last_6_final") || ($date == "$last_7_final") || 

($date == "$last_8_final") || ($date == "$last_9_final") || ($date == "$last_10_final")) {


if($x%2): $color = "#F7FBFB"; else: $color = "#FFFFFF"; endif;



print("Stufff prints here...");











$count += 1;

$x++;
}
}
}
}


    fclose($handle);

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.