The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Any comments would be helpful. I would like to know if what i have done is correct as i got the output correctly, but it didn't work with PHPLib Template. Thus, I would also like to know how to have the data in the txt file to be used with PHPLib Template. How do i passed the data to a variable? (possible?)

What is it you are trying to do with PHPLIB just put the contents of the text file in to the {codes} portion of your template? Or is there something we are missing here? It appears you are trying to use a block in the template, if this is the case please let us know. Right now what you are doing is taking the whole text file and putting it in a variable named $data then assigning $data to $temp then putting $temp into the template. Where is your code to set up the template? If you show us this and explain exactly what you want to do with the text file we can be of more assistance.

Please don't PM me with questions.
Use the forums, that is what they are here for.

OKay so, when you use the fopen method you showed below you are basically grabbing every line from the text fiel and putting into one variable in this case $data. Now you are using a block in the template which is normally reserved for repeating chunks of code. If this is what you intended you probably should have used file() instead of fopen() and fread();

So for your case I would have done this. BTW the reason yours didn't work is because the variable conflict of your template handle "codes" and your block var "codes", notice how I changed your template handle to "code" and now it should work fine.

$data = file($path); // grab each line from file and put in an array
foreach($data as $key => $val) { //Loop through the array and assign each line to the block CodesBlock
$t->set_var('codes', $val);
$t->parse('CBlock', 'CodesBlock', true);
}

$t->pparse('Output', 'code');

?>

Please don't PM me with questions.
Use the forums, that is what they are here for.

First, i run a game codes website. I feel kinda troublesome by the fact that i still need to use html coding in the txt file. I would like some feedback from any professional web developer or anybody who knows a way to help me find a way to rid the html coding in the txt file via PHPLib or any other method. But there's one major problem:

Taking the coding above, as there are different datas for my case - one column holds the code number, one the code description (for example, NTSC Mode)and the other is the code value (35AC1D55CEED). Some games have codes upto thousands of them and i wouldn't want to write all those html stuff (repeat).

I've thought of entering the code datas via mysql but it would take time to enter all of them tho.