hockeyman10 Posted March 27, 2007 Share Posted March 27, 2007 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. Quote Link to comment Share on other sites More sharing options...
DeathStar Posted March 27, 2007 Share Posted March 27, 2007 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! Quote Link to comment Share on other sites More sharing options...
hockeyman10 Posted March 27, 2007 Author Share Posted March 27, 2007 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. Quote Link to comment Share on other sites More sharing options...
hockeyman10 Posted March 28, 2007 Author Share Posted March 28, 2007 Noone? Anything? I know there is such thing as time Deathstar but this sucks lol. Does anyone know what I need to do? can't get this working. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 28, 2007 Share Posted March 28, 2007 This will point you in the right direction. I personally find the table of contents near the bottom very useful. http://www.phpfreaks.com/phpmanual/page/ref.filesystem.html Quote Link to comment Share on other sites More sharing options...
hockeyman10 Posted March 29, 2007 Author Share Posted March 29, 2007 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? Quote Link to comment Share on other sites More sharing options...
AndyB Posted March 29, 2007 Share Posted March 29, 2007 like reversing an array??? http://ca.php.net/manual/en/function.array-reverse.php Quote Link to comment Share on other sites More sharing options...
hockeyman10 Posted March 30, 2007 Author Share Posted March 30, 2007 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); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.