Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Which method is better to read custom data?

Posted on 2011-09-07
5
236 Views
Last Modified: 2012-05-12
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:

- Beans
-- Rice     $0.99
-- Oat     $1.29
-- Weat     $1.19

- Meat
-- Pork     $2.99
-- Cow     $2.59
-- Chicken     $1.99

Open in new window


Thanks in advance!
0
Comment
Question by:Cesar Aracena
5 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 36500031
Have them do it in Excel and export it as CSV.  That's probably the simplest text format you could do quickly.
0
 
LVL 2

Expert Comment

by:shdwmage
ID: 36500087
well in HTML code your list would look something like this:

<li>Products
<ul>Beans
<li>Rice $0.99</li>
<li>Oat  $1.29</li>
<li>Weat $1.19</li>
</ul></li>
<li>Meat<ul>
<li>Pork $2.99</li>
<li>Cow $2.59</li>
<li>Chicken $1.99</li>
</ul></li>
</ul> 

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:
$beans = array("rice $0.99","oat $1.20","Weat $1.19");
$meat = array("pork 2.99","cow $2.59","chicken $1.99");

and then in the php file do the following
echo "<ul><li>Beans<ul>";
foreach ($beans as $value) {
    echo "<li> $value</li>\n";
}
echo "</li></ul>";
echo "<ul><li>Meats";
foreach ($meat as $value) {
    echo "<li> $value</li>\n";
}
echo "</li></ul>"

Open in new window


Other than that I don't know any quick easy ways to get around it.
0
 
LVL 2

Expert Comment

by:shdwmage
ID: 36500091
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.
0
 
LVL 6

Author Closing Comment

by:Cesar Aracena
ID: 36500260
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!
0
 
LVL 82

Expert Comment

by:hielo
ID: 36500294
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

;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

0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Moving from Mcrypt to OpenSSL 18 45
Magento: different theme for Pc and for mobile devices 4 32
Ajax and PHP 9 29
PHP delete contents of file- before writing to it 6 21
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question