I wanna make a file that holds the complete pricelist for a small
webshop (yes, I know that a database in the background would be a lot
simpler, but that is not an option today, unfortunately).
I'm thinking something like creating a file that holds the productname
and the price, and then just get the price from the other pages that
needs it. (Typically an overview page of all the products in a category,
and the spesific product pages).
I'm thinking it would be possible to create something like:
#Product 1
$produkt1 = 2000
#produkt 2
$produkt2 = 1400
and so on
Is this a good way to create this?
And what is the best way to get the informatin into the file that needs
to parse it? $GET? or something else entirely?
--
mvh
Ørjan Langbakk http://www.bergenpchjelp.no http://www.cubic-design.net 13 1878
Ørjan Langbakk wrote:
I wanna make a file that holds the complete pricelist for a small
webshop (yes, I know that a database in the background would be a lot
simpler, but that is not an option today, unfortunately).
I'm thinking something like creating a file that holds the productname
and the price, and then just get the price from the other pages that
needs it. (Typically an overview page of all the products in a
category, and the spesific product pages).
I'm thinking it would be possible to create something like:
#Product 1
$produkt1 = 2000
#produkt 2
$produkt2 = 1400
and so on
Is this a good way to create this?
Why not create an CSV, and use fgetcsv() and fputcsv() to get/store the
data? That way it's still pretty easy to update/add/delete stuff, and you
could even run a database somewhere else that would periodically upload a
changed csv easily. Maybe even parse_ini_file( ) could help you here, but I
doubt it will handle very nicely once the shop grows.
Grtz,
--
Rik Wasmus
Den 14.08.2006 16:21, skriblet Rik følgende:
Ørjan Langbakk wrote:
>I wanna make a file that holds the complete pricelist for a small webshop (yes, I know that a database in the background would be a lot simpler, but that is not an option today, unfortunately).
I'm thinking something like creating a file that holds the productname and the price, and then just get the price from the other pages that needs it. (Typically an overview page of all the products in a category, and the spesific product pages).
I'm thinking it would be possible to create something like:
#Product 1 $produkt1 = 2000 #produkt 2 $produkt2 = 1400
and so on
Is this a good way to create this?
Why not create an CSV, and use fgetcsv() and fputcsv() to get/store the
data? That way it's still pretty easy to update/add/delete stuff, and you
could even run a database somewhere else that would periodically upload a
changed csv easily. Maybe even parse_ini_file( ) could help you here, but I
doubt it will handle very nicely once the shop grows.
Well... I already have CSV-files of all the product-listing pages. But
what I want is _one_ file just holding the prices, basically - no other
info. The reason for this is that the prices change frequently (sales,
campaigns etc.) - therefore it would be much easier to just store each
price as a variable, and then get that variable on the pages that need
the price displayed.
So, I think maybe my original suggestion is better, if it works - will
it work?
--
mvh
Ørjan Langbakk http://www.bergenpchjelp.no http://www.cubic-design.net
Ørjan Langbakk wrote:
Den 14.08.2006 16:21, skriblet Rik følgende:
>Ørjan Langbakk wrote:
>>I wanna make a file that holds the complete pricelist for a small webshop (yes, I know that a database in the background would be a lot simpler, but that is not an option today, unfortunately).
I'm thinking something like creating a file that holds the productname and the price, and then just get the price from the other pages that needs it. (Typically an overview page of all the products in a category, and the spesific product pages).
I'm thinking it would be possible to create something like:
#Product 1 $produkt1 = 2000 #produkt 2 $produkt2 = 1400
and so on
Is this a good way to create this?
Why not create an CSV, and use fgetcsv() and fputcsv() to get/store the data? That way it's still pretty easy to update/add/delete stuff, and you could even run a database somewhere else that would periodically upload a changed csv easily. Maybe even parse_ini_file () could help you here, but I doubt it will handle very nicely once the shop grows.
Well... I already have CSV-files of all the product-listing pages. But
what I want is _one_ file just holding the prices, basically - no
other info. The reason for this is that the prices change frequently
(sales, campaigns etc.) - therefore it would be much easier to just
store each price as a variable, and then get that variable on the
pages that need
the price displayed.
So, I think maybe my original suggestion is better, if it works - will
it work?
It can work perfectly.
I'd prefer an array though: using a product id, and an include like:
<?php
$prices = array(
1 =1200,
2 =4200,
etc...
)
?>
But why not create a seperate csv (if you really want it seperate) if you're
already using it's capabilities?
1,1200
2,1400
etc...
It seems more logical/maintainable to me. It seems even more logical to me
to keep the price in the original CSV, and to maintain it there. It's not
that hard to write a framework than can manipulate a csv as easily as a flat
table.
Grtz,
--
Rik Wasmus
Den 14.08.2006 17:59, skriblet Rik følgende:
Ørjan Langbakk wrote:
>Den 14.08.2006 16:21, skriblet Rik følgende:
>>Ørjan Langbakk wrote: I wanna make a file that holds the complete pricelist for a small webshop (yes, I know that a database in the background would be a lot simpler, but that is not an option today, unfortunately).
I'm thinking something like creating a file that holds the productnam e and the price, and then just get the price from the other pages that needs it. (Typically an overview page of all the products in a category, and the spesific product pages).
I'm thinking it would be possible to create something like:
#Product 1 $produkt1 = 2000 #produkt 2 $produkt2 = 1400
and so on
Is this a good way to create this? Why not create an CSV, and use fgetcsv() and fputcsv() to get/store the data? That way it's still pretty easy to update/add/delete stuff, and you could even run a database somewhere else that would periodicall y upload a changed csv easily. Maybe even parse_ini_fil e() could help you here, but I doubt it will handle very nicely once the shop grows.
Well... I already have CSV-files of all the product-listing pages. But what I want is _one_ file just holding the prices, basically - no other info. The reason for this is that the prices change frequently (sales, campaigns etc.) - therefore it would be much easier to just store each price as a variable, and then get that variable on the pages that need the price displayed.
So, I think maybe my original suggestion is better, if it works - will it work?
It can work perfectly.
I'd prefer an array though: using a product id, and an include like:
<?php
$prices = array(
1 =1200,
2 =4200,
etc...
)
?>
But why not create a seperate csv (if you really want it seperate) if you're
already using it's capabilities?
1,1200
2,1400
etc...
It seems more logical/maintainable to me. It seems even more logical to me
to keep the price in the original CSV, and to maintain it there. It's not
that hard to write a framework than can manipulate a csv as easily as a flat
table.
Maybe? I'm not that capable at PHP (at least not yet) - What I wonder is
how I would take JUST that value (ie. the price) from the CSV-file I
already have?
Could I use a kind of one-liner to just put in the last group in the CSV
(the price is always last)?
And, as I am also new to the array-functions, how would I go around
creating that file, and pulling the different values from it?
I'm thinking I could use something like:
<?php
$prices = array (
product1 =1200,
product2 =2400,
product3 =3450,
)
?>
Would this work? Does the names have anything to say? And, to pull one
value from this file - how would I do that? Assuming that this is put in
a separate PHP-file, that is. Like eg. prices.php
Would I use something like <?php $_GET["prices.php "] $prices="produc t1"
???
--
mvh
Ørjan Langbakk http://www.bergenpchjelp.no http://www.cubic-design.net
But why not create a seperate csv (if you really want it seperate) if you're
already using it's capabilities?
...It seems more logical/maintainable to me. It seems even more logical to me
to keep the price in the original CSV, and to maintain it there. It's not
that hard to write a framework than can manipulate a csv as easily as a flat
table.
I agree totally. I store a list of about 40 unit rate prices for our online
quote system as a very small .csv file, and our cost estimating staff can easily
load it in Microsoft Excel and play with it all they want without having to get
into databases at all. When they're finished, I upload it to the server easy as
pie.
Ørjan Langbakk wrote:
And, as I am also new to the array-functions, how would I go around
creating that file, and pulling the different values from it?
I'm thinking I could use something like:
<?php
$prices = array (
product1 =1200,
product2 =2400,
product3 =3450,
)
?>
To do this, put that $prices array in a file all by itself.
Then, from the page that needs to use this data, use require_once [1]
to include the file.
To access the data for a specific product, then, you would say, for
example, $prices['product1'].
This can be a very easy to implement solution, but difficult to
maintain in the long run. I agree with those advocating using, at the
very least, CSV (though I've never done it, so probably won't be of
much help). Once someone decides they want to do more with the website
and/or the data, you are going to wish you had a more flexible data
backend than an include file with an array.
[1] - http://us2.php.net/manual/en/function.require-once.php
Den 14.08.2006 22:23, skriblet Gary Hasler følgende:
>But why not create a seperate csv (if you really want it seperate) if you're already using it's capabilities?
>...It seems more logical/maintainable to me. It seems even more logical to me to keep the price in the original CSV, and to maintain it there. It's not that hard to write a framework than can manipulate a csv as easily as a flat table.
I agree totally. I store a list of about 40 unit rate prices for our online
quote system as a very small .csv file, and our cost estimating staff can easily
load it in Microsoft Excel and play with it all they want without having to get
into databases at all. When they're finished, I upload it to the server easy as
pie.
Well... I use TextPad for my webcoding, and has no problems using that
with custom highlights for CSV :)
But still, I kinda don't understand how I would extract only ONE value
for each row in the CSV file, into the other file. If someone can point
me in the right direction for something like that, it would be great -
the lesser the files to maintain, the better.
--
mvh
Ørjan Langbakk http://www.bergenpchjelp.no http://www.cubic-design.net
Den 14.08.2006 22:41, skriblet mo************* ******@yahoo.co m følgende:
Ørjan Langbakk wrote:
>And, as I am also new to the array-functions, how would I go around creating that file, and pulling the different values from it?
I'm thinking I could use something like:
<?php $prices = array ( product1 =1200, product2 =2400, product3 =3450, ) ?>
To do this, put that $prices array in a file all by itself.
Then, from the page that needs to use this data, use require_once [1]
to include the file.
To access the data for a specific product, then, you would say, for
example, $prices['product1'].
Wouldn't that mean that it would have to read through the entire
prices.php file, to get the one value I need? I mean, using require_once.
Wouldn't it be possible to just use the $_GET variable or something,
using the prices.php as the file from where to get the data?
Or is the require_once the best way of doing this?
--
mvh
Ørjan Langbakk http://www.bergenpchjelp.no http://www.cubic-design.net
Den 14.08.2006 22:41, skriblet mo************* ******@yahoo.co m følgende:
Ørjan Langbakk wrote:
>And, as I am also new to the array-functions, how would I go around creating that file, and pulling the different values from it?
I'm thinking I could use something like:
<?php $prices = array ( product1 =1200, product2 =2400, product3 =3450, ) ?>
To do this, put that $prices array in a file all by itself.
Then, from the page that needs to use this data, use require_once [1]
to include the file.
To access the data for a specific product, then, you would say, for
example, $prices['product1'].
This can be a very easy to implement solution, but difficult to
maintain in the long run. I agree with those advocating using, at the
very least, CSV (though I've never done it, so probably won't be of
much help). Once someone decides they want to do more with the website
and/or the data, you are going to wish you had a more flexible data
backend than an include file with an array.
[1] - http://us2.php.net/manual/en/function.require-once.php
Hm. Well, I got it to work, but not as I wanted to. Okey, the file
prices.php and the require_once all work fine, but since I already
include a CSV-file with all the specific details about each product, I
need the <?php echo $prices['product1']; ?to be _in_ the CSV file I
parse - and THAT seems to be a problem, since the code just shows up in
the page source code, it's not being parsed, and I wonder how I can
correct this?
--
mvh
Ørjan Langbakk http://www.bergenpchjelp.no http://www.cubic-design.net This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark Parnell |
last post by:
I'm relatively new to PHP, and have just converted a site from ASP to
PHP. There is one thing I haven't managed to do, though.
When the site was using ASP, I had one file (called variables.asp),
where I defined various variables that are used throughout the site. I
could then access all of these in any other file by simply including
that file (using #include), then referencing the variables.
I have been unable to do the same thing in...
|
by: Nicolas Lebas |
last post by:
hello,
i don't know if this is the best list to send this question, but i'm
already trying to ask.
I need to import variables from .RData files (arrays or variables).
I'm trying to use the rpy module, but without success beccause when i
try to access to a variable loaded from the .RData file i have a
segmentation fault !
|
by: Randy |
last post by:
Hello,
I'm having a strange problem. I've got a .NET web app which uses Session
variables. Sometime, not all the time, they get cross threaded...that
is...one user will have another user's Session variable(s) data assigned to
them. I can't figure out why. I've read that other people are having this
problem too but I haven't found a resolution yet. Can someone please tell me
how I might go about fixing this?
Thanks
|
by: zeecanvas |
last post by:
Hi,
First of all: Yes, I know global variables are bad, but I've a huge
amount of legacy code, and I've to maintain it _as_is_.
I'm maintaining a big program. I moved all (program-wide scope) global
variables outside of the files they were defined it, and created some
files that just hold global variables definitions (just variables,
without any function definition). So, depending on the purpose/category
of variables, they're defined...
|
by: Tristan |
last post by:
Hello community:
I post this because I could not find satisfactory answers in the posts
generated by this nice group.
I work on winXP. I have many little python applications in different
folders, each application can share or not other objects located in the
same or other folders.
The way I work to use these applications is:
1) For almost everyone, I execute a corresponding ".bat file" into
| |
by: Sandman |
last post by:
I dont think I understand them. I've read the section on scope in the
manual inside out.
I'm running PHP 5.2.0 Here is the code I'm working on:
//include_me.php
<?php
$MYVAR = array();
global $MYVAR, $a;
?>
|
by: tcurdts |
last post by:
Greetings,
I'm using WindowsXP Pro v5.1and am writing a BAT file to loop through a list of files (contained in a .txt file) and pass them (actually variables derived from them) to another program (ERDAS Imagine). What appears to be happening is that the FOR loop isn't utilizing the variables until the 2nd iteration after the variable is set. Since one variable is dependent on another, I have to run the program 3 times before the variables...
|
by: bhavanirayala |
last post by:
Hi,
I am sending the values from one method to another method to get the values from xml file based on the inputs.
I am getting the error like::
Variable "$collType" will not stay shared
Variable "$collState" will not stay shared at line 77.
please see the below code and help me out.
|
by: weaknessforcats |
last post by:
C++: The Case Against Global Variables
Summary
This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition.
The opinions expressed in this article are those of the author alone although many have...
|
by: alphasahoo |
last post by:
Hi
I am working on a program which writes the output a SQL select statements from number of source tables first to a load matrix and then writes to a load.dat file.
But while writing to the load.dat file, the program gets stuck if I am putting float variables getting rounded to 8 or 9 decimal places.
But runs fine if the float variable getting rounded to 6 decimal places.
The code snippet is below:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |