Cesar Aracena
asked on
Which method is better to read custom data?
Hello everybody,
I've been asked to make a pretty simple website with only one page and a list of items being sold. The list has to be separated in cathegories and needs to be very simple to update by hand but I don't have more than 3 days to make it so I can't make a control panel or something fancy. I need the user to be able to fill up a file (txt file, excel or something like that) and upload it to the server so the site is automatically updated.
What would be the best way to go? XML seems a little too complicated for a non-technical person to fill every other day and I really don't know how to make "sub-cathegories" in a text file so each group of items are displayed under their corresponding cathegory.
In example, I would need something like the following:
Thanks in advance!
I've been asked to make a pretty simple website with only one page and a list of items being sold. The list has to be separated in cathegories and needs to be very simple to update by hand but I don't have more than 3 days to make it so I can't make a control panel or something fancy. I need the user to be able to fill up a file (txt file, excel or something like that) and upload it to the server so the site is automatically updated.
What would be the best way to go? XML seems a little too complicated for a non-technical person to fill every other day and I really don't know how to make "sub-cathegories" in a text file so each group of items are displayed under their corresponding cathegory.
In example, I would need something like the following:
- Beans
-- Rice $0.99
-- Oat $1.29
-- Weat $1.19
- Meat
-- Pork $2.99
-- Cow $2.59
-- Chicken $1.99
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'd like to note I don't encourage the use of the above as it is a bad coding practice in my opinion and I would only ever use it as a testing purpose.
ASKER
Thanks to both of you. DaveBaldwin's answer was much straight to the point. Althought the second answer was more complex, it would be something harder for the user to fill.
Thanks again!
Thanks again!
my suggestion would be to use an ini file and then use parse_ini_file() function:
http://php.net/manual/en/function.parse-ini-file.php
http://php.net/manual/en/function.parse-ini-file.php
;Here's your sample products.ini file
;Do not include the dollar sign for the prices.
;Also keep one item per line
[Grains]
Rice=0.99
Oat=1.29
Wheat=1.19
[Meat]
Pork=2.99
Cow=2.59
Chicken=1.99
<?php
//sample php
$items = parse_ini_file('/path/to/your/products.ini', true);
echo $items['Grains']['Oat'];
?>
Open in new window
That code will show bullets with sub-bullets for the lower categories. Quickest, dirtiest way to do it.
I would spend the time to write the administration section and just put it in a database and have the data formatted by the php.
Additionally there is another cheap dirty way to do this (again not my cup of tea), setup a text file like the following:
Open in new window
Other than that I don't know any quick easy ways to get around it.