473,811 Members | 3,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If statement within an if statement

I am a complete novice with php scrip but I am wiling to learn.
I am in need of some help, please.

Can anyone sort this code out for me so that it works correctly and
adjusts the price for the quantity selected on the front end.
_______________ _______________ _______________ _______________ ___

if(article_get_ field('type')== 'Croclight Candle'){
article_set_fie ld('item_number ', 'CRC');
article_set_fie ld('price', 6.99);
}
elseif(article_ get_field('type ')== 'Spray') {
article_set_fie ld('item_number ', 'CRS');
article_set_fie ld('size', '50ml');
article_set_fie ld('price', 6.99);
}
elseif(article_ get_field('size ')== '15ml') {
article_set_fie ld('item_number ', 'CRS');
article_set_fie ld('type', 'Spray');
article_set_fie ld('price', 2.99);
}
elseif(article_ get_field('type ')== 'Roll-on') {
article_set_fie ld('item_number ', 'CRO');
article_set_fie ld('size', '50ml');
article_set_fie ld('price', 6.99);
}
_______________ _______________ _______________ _______________ ____

Thanks in advance

Mark

Aug 22 '05 #1
30 6420
"Mark" <ma************ @ntlworld.com> wrote in
news:11******** **************@ g49g2000cwa.goo glegroups.com:
I am a complete novice with php scrip but I am wiling to learn.
I am in need of some help, please.

Can anyone sort this code out for me so that it works correctly and
adjusts the price for the quantity selected on the front end.
_______________ _______________ _______________ _______________ ___

if(article_get_ field('type')== 'Croclight Candle'){
article_set_fie ld('item_number ', 'CRC');
article_set_fie ld('price', 6.99);
}
elseif(article_ get_field('type ')== 'Spray') {
article_set_fie ld('item_number ', 'CRS');
article_set_fie ld('size', '50ml');
article_set_fie ld('price', 6.99);
}
elseif(article_ get_field('size ')== '15ml') {
article_set_fie ld('item_number ', 'CRS');
article_set_fie ld('type', 'Spray');
article_set_fie ld('price', 2.99);
}
elseif(article_ get_field('type ')== 'Roll-on') {
article_set_fie ld('item_number ', 'CRO');
article_set_fie ld('size', '50ml');
article_set_fie ld('price', 6.99);
}


First suggestion: Avoid elseif's if at all possible. Use the switch()
statement instead. <see http://www.php.net/switch>

switch (article_get_fi eld('type')) {
case 'Croclight Candle':
article_set_fie ld('item_number ', 'CRC');
article_set_fie ld('price', 6.99);
break;
case 'Spray':
article_set_fie ld('item_number ', 'CRS');
article_set_fie ld('size', '50ml');
article_set_fie ld('price', 6.99);
break;
case 'Roll-on':
article_set_fie ld('item_number ', 'CRO');
article_set_fie ld('size', '50ml');
article_set_fie ld('price', 6.99);
break;
}

if(article_get_ field('size') == '15ml') {
article_set_fie ld('item_number ', 'CRS');
article_set_fie ld('type', 'Spray');
article_set_fie ld('price', 2.99);
}

Also, when posting code, try to use indentation so that the different
code blocks can be determined.

Ken

Aug 22 '05 #2
<comp.lang.ph p , Ken Robinson , se**********@rb nsn.com>
<1124745948.eba 2d174dc98eac000 e32e39523bcf98@ teranews>
<Mon, 22 Aug 2005 21:25:48 GMT>
First suggestion: Avoid elseif's if at all possible. Use the switch()
statement instead. <see http://www.php.net/switch>

switch (article_get_fi eld('type')) {snip code}

Also, when posting code, try to use indentation so that the different
code blocks can be determined.


That looked a nice bit of code and i've been meaning to learn about
switch() for ages , But i'm the opposite and most of the time I regard
indents as a curse .

if ($poo<>$poo)
{
php code
}

Each to their own .
--
www.phpguestbook.co.uk
Aug 23 '05 #3
PHPGB wrote:

That looked a nice bit of code and i've been meaning to learn about
switch() for ages , But i'm the opposite and most of the time I
regard indents as a curse .

if ($poo<>$poo)
{
php code
}

Each to their own .

You'll find that proper indentation is almost universal amongst
programmers. There's a very good reason for that, having to do with
being able to read, debug, and maintain large code sections.

I recommend strongly that you start doing the same. Many code editors
help you out these days through auto-indenting. Use spaces, not tabs,
especially for posting code to usenet.


Brian
Aug 23 '05 #4
<comp.lang.ph p , Default User , de***********@y ahoo.com>
<3n************ *@individual.ne t>
<23 Aug 2005 21:57:29 GMT>
if ($poo<>$poo)
{
php code
}

Each to their own .

You'll find that proper indentation is almost universal amongst
programmers. There's a very good reason for that, having to do with
being able to read, debug, and maintain large code sections.


And if all the other programmers put their hand in the fire you would
want me to do the same would you ? :-)

I've always been in the frame of mind its what suits the person and not
what suits anybody else .
--
www.phpguestbook.co.uk
Aug 24 '05 #5
Fair enouph, just dont expect assistance from the community then.

PHPGB wrote:
<comp.lang.ph p , Default User , de***********@y ahoo.com>
<3n************ *@individual.ne t>
<23 Aug 2005 21:57:29 GMT>
if ($poo<>$poo)
{
php code
}

Each to their own .

You'll find that proper indentation is almost universal amongst
programmers . There's a very good reason for that, having to do with
being able to read, debug, and maintain large code sections.

And if all the other programmers put their hand in the fire you would
want me to do the same would you ? :-)

I've always been in the frame of mind its what suits the person and not
what suits anybody else .

Aug 24 '05 #6
PHPGB wrote:
<comp.lang.ph p , Default User , de***********@y ahoo.com>
<3n************ *@individual.ne t>
<23 Aug 2005 21:57:29 GMT>
if ($poo<>$poo)
{
php code
}

Each to their own .

You'll find that proper indentation is almost universal amongst
programmers . There's a very good reason for that, having to do with
being able to read, debug, and maintain large code sections.

And if all the other programmers put their hand in the fire you would
want me to do the same would you ? :-)

I've always been in the frame of mind its what suits the person and not
what suits anybody else .


Gee, if all the other programmers were doing it, there must be a reason!

After almost 40 years of programming, I've found indenting is VERY important.
And I second Ramon's opinion - don't expect help from the group - or any other
programmer. And don't expect to ever get a job programming.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Aug 24 '05 #7
<comp.lang.ph p , Jerry Stuckle , js*******@attgl obal.net>
<q5************ ********@comcas t.com>
<Tue, 23 Aug 2005 20:23:49 -0500>
And if all the other programmers put their hand in the fire you would
want me to do the same would you ? :-)

I've always been in the frame of mind its what suits the person and not
what suits anybody else .


Gee, if all the other programmers were doing it, there must be a reason!

After almost 40 years of programming, I've found indenting is VERY important.
And I second Ramon's opinion - don't expect help from the group - or any other
programmer.


Calm down lads .
'don't expect help from the group'

Do you realise what you have just said ? .

Professional programmers acting like foot stomping little children who
wont help a user because they use a different method than their own .
--
www.phpguestbook.co.uk
Aug 24 '05 #8
PHPGB wrote:
<comp.lang.ph p , Default User , de***********@y ahoo.com>
<3n************ *@individual.ne t>
<23 Aug 2005 21:57:29 GMT>
if ($poo<>$poo)
{
php code
}

Each to their own .

You'll find that proper indentation is almost universal amongst
programmers. There's a very good reason for that, having to do with
being able to read, debug, and maintain large code sections.


And if all the other programmers put their hand in the fire you would
want me to do the same would you ? :-)


Why would they? You seem to labor under the delusion that thousands of
professionals don't know what they are doing or would be malicious in
their advice. They do and they wouldn't be.
I've always been in the frame of mind its what suits the person and
not what suits anybody else .


Why do you find it has any benefit?

More importantly, posting unindented code to the newsgroup will cause
at least some people to ignore you.

Brian
Aug 24 '05 #9
No, this has nothing to do with adolescent tantrums. The reason for the
hostile behavior, is because after being involved in the industry. There
is nothing quite like walking into a new and *exciting* job opportunity,
and then finding that you are responsible for maintaining the code of a
12 year old who was stuck inside a 45 year old's body. Or simply said
was too lazy to comment and indent.

And it takes you 10x the time to interpret what was written as there is
no documentation of any kind (if you are lucky you will get some PHPdoc
crap which isnt of much use either. Oh wait, its even better if you are
a team leader and you are in charge of integration 10 large scale
systems, into one cohesive one. While because 5 out of the 10 systems in
question were written by this same 12 year old.

Still wondering where the hostility stems from? Or did you get the drift?
PHPGB wrote:
<comp.lang.ph p , Jerry Stuckle , js*******@attgl obal.net>
<q5************ ********@comcas t.com>
<Tue, 23 Aug 2005 20:23:49 -0500>
And if all the other programmers put their hand in the fire you would
want me to do the same would you ? :-)

I've always been in the frame of mind its what suits the person and not
what suits anybody else .


Gee, if all the other programmers were doing it, there must be a reason!

After almost 40 years of programming, I've found indenting is VERY important.
And I second Ramon's opinion - don't expect help from the group - or any other
programmer.

Calm down lads .
'don't expect help from the group'

Do you realise what you have just said ? .

Professional programmers acting like foot stomping little children who
wont help a user because they use a different method than their own .

Aug 24 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14785
by: David | last post by:
Hi, Quick question. If I have a recordset value in RS("ProductName"), is it possible to test for a part string in this value ? I would be looking for all products starting 'Blue' and with misc endings. So I will require the search string Blue.*
4
21352
by: Thomas Jerkins | last post by:
When I write a create table SQL statement I want to add some information about the column heading of each column. How does the exact syntax for the create table look like (which includes this column data look)? How do I add later column headings ? Tom
35
8365
by: Thomas Matthews | last post by:
Hi, My son is writing a program to move a character. He is using the numbers on the keypad to indicate the direction of movement: 7 8 9 4 5 6 1 2 3 Each number has a direction except for '5'. So in his switch statement, he omits a case for '5':
1
3073
by: mirandacascade | last post by:
O/S: Windows 2K Vsn of Python: 2.4 Currently: 1) Folder structure: \workarea\ <- ElementTree files reside here \xml\ \dom\
7
11447
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And #11/2/2003# And VehicleID='00000000' And BattID='LKO500HF'. I need to use the records returned to populate text boxes, but the data requires further manipulation. I attempting to use expressions in the control source
6
5722
by: Arjen | last post by:
Hi, I'm reading the enterprise library documentation and there I see the throw statement. try { // run code } catch(Exception ex) {
10
2371
by: John Smith | last post by:
Can you do a Select Statement within a Select Statement? I want to build a query similar to queries built in Access which link to other queries but using only SQL Statements. Is it possible? If so, how do you do it? Thanx in adv.
13
2578
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){}, my_meth2: function(){} }); to define new methods on the MyObj prototype object. Object.extend
18
7980
by: dspfun | last post by:
Hi! The words "expression" and "statement" are often used in C99 and C- textbooks, however, I am not sure of the clear defintion of these words with respect to C. Can somebody provide a sharp defintion of "expression" and "statement"? What is the difference between an expression and a statement?
2
21113
by: ianmcdonagh | last post by:
Hi folks, I'm looking to pick everyone's brains. I have a cursor, with over 200 columns in the select. I am using a case in one of the columns which I'm retrieving, and want to issue an insert statement within this. i know people will come back with different merge or whatever, but i must be able to do this within a case statement unfortunately. example
0
10379
jinu1996
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...
0
10127
tracyyun
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...
0
9201
agi2029
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...
1
7665
isladogs
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...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5552
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...
1
4336
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
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.