Display specific record number based on selection
How would I add code to the page to SELECT a specific record number based on client requirements. There are multiple list record pages, one for default, one for club discount prices, one for earlybirds. I need to insert a specific pricing record in an area depending on the promotional page. For example, on the club promotion page, it needs to show the club discount prices. On the normal pages, it needs to display the default prices. My client may also add more pricing list pages, so it needs to be flexible. I am going around in circles trying to work out how to do this, but ?? Any help would be appreciated.
If users need to be logged in to get special promotional rates, you should be able to use a where and/or if to match the category of the customer from their accounts record (normal, club discount, etc) to a key field in your rates records to determine which record will be displayed.
You could use the website membership plugin to do some of the heavy lifting of determining who is logged in and their account status. (non logged in folks get the normal rates, logged in users would get a rate page based on a fild that lists their account status))
If they don't, if there's is a time dependency (if there's an early bird period then that could be the criteria for matching the $where. If date is greater than a and les than be then $where= 'earlybird' etc.)
If it's just in answer to an email, then pass the value of the promo page in the link matching the key field in the rates records.
Or, it could be a combination of all of the above, (where's can be extremely complex)
In any case I'd set up a master multi record section with list of categories that need to be matched (maybe with a simpler title and a complex coded key field to help to lessen the ability to access the wrong prices) and used that to populate drop downs in the account record, the pricing records or any place else the information is needed, so spellings will always match.
Then use a $where in the list records call to determine the record that's displayed.
There are some recipes in the CMSB cookbook that should be of help with some of the specifics.
Good luck with this, and please share your resulting code if you can so others can learn too.
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Hi Carol - definately possible.
I would add an additional field to the promotional-pages section, called "price" which is a list that pulls from the "prices" section.
The prices section would have a title and value field, where the title is "Club Discount" etc, and the value is "99.00" for $99.00 etc.
Then, in the page php, use the value of the price field in the form.
Thank you... I've done that, but can't work out how to get, for example, price record 2 on promotional page 1 or price record 5 on promotional page 4.I'm sure it's a "where = etc", but I can't work out the code snippet.
Any advice would be gratefully appreciated.
A simple way to retrieve a specific record based on its num field, you can use the mysql_get() function like this:
$pricingRecord = mysql_get('pricing', $pricingNum);
You will need to alter this for your specific case; the first argument 'pricing' is the table name of the pricing section, and $pricingNum will be the record number you're trying to select.
Let me know if that helps, or if you have any further questions.