Posted: Mon Oct 08, 2007 4:38 am Post subject: Import Text File
Hi. I am new to PHP development and I am working on a very small project right now that I thought would be the perfect place for me to dive in and learn. So far, so good but the question I have is about importing a .txt file. I have the file importing properly and the CSS is applying properly but what I want to know is how to have a single .txt but attach variables to certain lines to just pull data from that section. This is hard to describe so here is the link to the page that I am working on:
The area I am referring to is the Title(s) and product description. Is there a way that all of that data can be in a single text file but by adding varibles or arrays to lines that when you click on one of the circles to see another product that the copy area will change as well? I work a lot in Flash and have done that there many times but was not sure if it is possible with just PHP or do I actually need to build a small MySQL database? Since there will not be a ton of data here, I was trying to keep this as simple as possible.
Joined: 02 May 2004 Posts: 6059 Location: toronto, canada
Posted: Tue Oct 16, 2007 3:23 am Post subject:
That took a few rereads to make sense of what you really wanted. You are using the text file as the data source and you want to change the presentation based on something clicked on the client...
If that is correct, you can do something similar, but if you want the same user experience, you will need to use AJAX, otherwise you will need to reload the page each time.
You can simulate this by reading the file into an array, assuming that each line is the complete elements list of for one record. Then you can show the user some piece of that array as the item...when the user clicks the link, you do an AJAX call to the server, repeat the same page that you used to do the initial html, passing in the parameter of the element that you want. The parameter likely to the index element of the array that would hold the data.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum