For a year, a lot of landings have spawned with the same product and their variations, where it has become very laborious to update prices. I am looking for a solution to keep prices in one file, and on the landing pages to somehow display them. But I do not know how, please tell me some solution.

For example: in the file store prices for 15 phone models (with some tags or tags, and not just a number), and there are 4-5 landing pages on each of 3-5 phones, sometimes they are repeated.

The output from the txt file here was close, but all the content is displayed here, but I’d somehow like to choose a specific line.

  • and just in js to bring a bunch of all sorts of var and display them where necessary, option? - user33274
  • and in variable var to bring from php - user33274
  • 2
    @ MaksimLensky to create a bunch of variables in js - I never saw a more ingenious answer ... - Manitikyl
  • @Appler what is the problem stored in the database? Indexed search is much nicer than working with files (although it is slower, but you will not feel the difference). - Manitikyl
  • @Manitikyl and what's the problem then? so you can not do? - user33274

2 answers 2

... The output from the txt file here was close, but all the content is displayed here, but I would somehow choose a specific line ...

Just go here: http://php.net/manual/ru/function.file.php

We see:

file - Reads the contents of a file and puts it into an array.

Those. we have a file FILE.TXT with the contents:

 Строка 0 Строка 1 Строка 2 Строка 3 

To output Строка 2 , you just need:

 $INPUT_FILE = file("FILE.TXT"); echo $INPUT_FILE[2]; 
  • Only the second line is $INPUT_FILE[1]; - Grulex
  • @AlexanderGrushko meant Строка 2 , corrected - Manitikyl

Where to store - in the database. How to select a specific line - through where in the SQL query.

If you want a more specific answer, ask a more specific question.