Reply to Re: Getting variables from another file

Your name:

Reply:


Posted by �rjan Langbakk on 08/15/06 08:21

Den 15.08.2006 04:22, skriblet Jerry Stuckle følgende:
>
> You're going to want to extract at least 2 values - the item number and
> the price. Otherwise, what happens if, for instance, the first line got
> deleted? You might be selling a $75,000 Jaguar for $0.75.

Nope. I'll want to extract ONE value :)

You see, the CSV-file in question is the basis for the product
categories - if something gets deleted, it will show up pretty soon on
the screen, so to speak - not to forget that using XHTML 1.0 Strict, any
parsing error will make the page break - which in turn of course will
show that there is an error. So, how do I, simply, extract everything
that is placed behind the _last_ comma in a CSV-file? As the price
itself isn't a set size (it varies from several prices, to only one, so
the length is fairly unpredictable). I will want to make this possible
to extract into several files.

As it is now, I have one page detailing each of the product categories.
These pages loads the appropriate CSV-file, and lists it's values as a
table.

Now, in the CSV-files, I've got everything from 6 to 60 products - maybe
more as the time goes by. What I need to do is something like extract
the value that is stored in the last field (after the last comma) into
several files.

> Using require_once is easy - but it means you have to parse the entire
> file. If it's long, that might be a problem. A csv file requires you
> to parse every line until you get to the one you want (unless you have
> fixed length blocks of data, random access will not work).

Well. I tried the require_once suggestion, and ran into trouble as the
price I'm trying to parse, is set into the CSV-file where I get the rest
of my data. For some reason the php-code I put in the appropriate field
in the CSV won't parse. I'm thinking maybe it's a quote-error somewhere,
or maybe it's in the way I parse the CSV into the html-file. I don't know.

And, besides, I still need to get ONLY the value from the price-field
into the singelpage product descriptions. Which I have NO clue as to how
to do with CSV.

The best way would be to just have a single file with all the prices,
and call up an arrayparameter in BOTH the CSV-file and the singlepage
product description - but as I already said, the php-code in the
CSV-file doesn't parse. It just sits in the source code when I'm looking
into it - which tells med that the server doesn't see it as php at all,
but as pure tekst, or something - it's not visible, so I'm guessing it
interprets it at comments or something.

Is there a way, or some tips as to what to look for, when it comes to
parsing php-code in CSV-files?

--
mvh
Ørjan Langbakk
http://www.bergenpchjelp.no
http://www.cubic-design.net

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация