# Thread: EASY IF THEN statement help

1. Registered User
Join Date
Aug 2005
Posts
12

## EASY IF THEN statement help

Ok, I've been having this crazy problem that sounds simple, but when you put it through testing. It all looks good until that one scenario destroys the whole code.

What I'm trying to do is develop and IF STATEMENT that meets this criteria:

Interval
sale1
sale2
sale3

Start Date
11-1-05
12-2-05
12-23-05

End Date
12-1-05
12-31-05
12-31-05

Price
10
20
30

count
101
0
0

Max
101
102
103

with the above value the
currentprice = 20

As you can see I have 3 different sale intervals with different starting dates.
Each interval also has a max count. Once the max has been reached the price goes up one level disregarding the starting date of the next level.
Code:
```This is what I have so far to measure for dates

currentdate = now()

IF currentdate > date1 THEN
currentprice = 10

IF currentdate > date2 THEN
currentprice = 20

IF currentdate > date3 THEN
currentprice = 30
END IF

END IF

END IF

This is what I have so far to measure for count/max.

IF count1 < max1 THEN
currentprice = 10

IF count2 < max2 THEN
currentprice = 20

IF count3 < max3 THEN
currentprice = 30
END IF

END IF

END IF

They both work independently.

(((I just don't know how to combine the two correctly.)))```
Any IDEAS appreciated.

2. if you are pulling this from a database, it might be easier to do this using the SQL rather than the server side script.

Are you pulling the sales prices, amounts and dates from a database?

3. Code:
```IF currentdate > date1 OR count1 < max1 THEN
currentprice = 10

ELSEIF currentdate > date2 OR count2 < max2 THEN
currentprice = 20

ELSEIF currentdate > date3 OR count3 < max3 THEN
currentprice = 30

END IF```
Change the OR to AND if you want both operations to be true.

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

"

"

## X vBulletin 4.2.2 Debug Information

• Page Generation 0.09025 seconds
• Memory Usage 2,842KB
• Queries Executed 13 (?)
Template Usage (33):
• (2)bbcode_code
• (1)footer
• (1)forumjump
• (1)forumrules
• (1)gobutton
• (3)memberaction_dropdown
• (1)navbar
• (1)navbar_moderation
• (1)navbar_noticebit
• (1)navbar_tabs
• (2)option
• (3)postbit
• (3)postbit_onlinestatus
• (3)postbit_wrapper
• (1)spacer_close
• (1)spacer_open
• (1)tagbit_wrapper

Phrase Groups Available (6):
• global
• inlinemod
• postbit
• posting
• reputationlevel
Included Files (26):
• ./global.php
• ./includes/class_bootstrap.php
• ./includes/init.php
• ./includes/class_core.php
• ./includes/config.php
• ./includes/functions.php
• ./includes/class_friendly_url.php
• ./includes/class_hook.php
• ./includes/class_bootstrap_framework.php
• ./vb/vb.php
• ./vb/phrase.php
• ./includes/functions_calendar.php
• ./includes/functions_bigthree.php
• ./includes/class_postbit.php
• ./includes/class_bbcode.php
• ./includes/functions_reputation.php
• ./includes/functions_notice.php
• ./packages/vbattach/attach.php
• ./vb/types.php
• ./vb/cache.php
• ./vb/cache/db.php
• ./vb/cache/observer/db.php
• ./vb/cache/observer.php

Hooks Called (70):
• init_startup
• friendlyurl_resolve_class
• init_startup_session_setup_start
• database_pre_fetch_array
• database_post_fetch_array
• init_startup_session_setup_complete
• global_bootstrap_init_start
• global_bootstrap_init_complete
• cache_permissions
• fetch_foruminfo
• global_state_check
• global_bootstrap_complete
• global_start
• style_fetch
• global_setup_complete
• strip_bbcode
• friendlyurl_clean_fragment
• friendlyurl_geturl
• forumjump
• cache_templates
• cache_templates_process
• template_register_var
• template_render_output
• fetch_template_start
• fetch_template_complete
• parse_templates
• notices_check_start
• notices_noticebit
• process_templates_complete
• friendlyurl_redirect_canonical
• bbcode_fetch_tags
• bbcode_create
• postbit_factory
• postbit_display_start
• postbit_imicons
• bbcode_parse_start
• bbcode_parse_complete_precache
• bbcode_parse_complete
• postbit_display_complete
• memberaction_dropdown
• tag_fetchbit_complete
• forumrules
• navbits
• navbits_complete