...

View Full Version : how to display a changeing number eg "displaying tip 1 of XX" where xx changes



nadley
05-14-2011, 11:30 AM
i have several "tips" on my website that i offer. I number these tips eg "displaying tip 27 of 56". Because i am adding to these tips i want to know how i can set the "56" to a look up the current number im at. Eg if i add 4 more tips today - i goto my file (excel or php or what ever) and change my total to "60" then every display on all my pages changes to reflect i have 60 tips now. So the same tip, when next viewed would say "displaying tip 27 of 60". This way i dont have to manually change every page on my website that has these tips on them.

Any ideas would be greatly welcomed

Suvi
05-14-2011, 11:50 AM
I am not completely sure what you mean, but I have seen in my own experiences that if you want one element to change on several pages without you manually going to every page, using a template for those pages would be the best way to go. That way whenever you change one thing on the template, every page with the template applied to it changes, as well.

Again, I'm not sure if that's exactly what you were asking, but I know that if I wanted to change something that affects my whole website, I would be using the website's template to do it.

nadley
05-14-2011, 12:01 PM
I am not completely sure what you mean, but I have seen in my own experiences that if you want one element to change on several pages without you manually going to every page, using a template for those pages would be the best way to go. That way whenever you change one thing on the template, every page with the template applied to it changes, as well.

Again, I'm not sure if that's exactly what you were asking, but I know that if I wanted to change something that affects my whole website, I would be using the website's template to do it.

Thanks Suvi
I cant use a template because each tip is unique and its number remains the same. Its just the total number if tips id like to have change on each page, as they grow.

Suvi
05-14-2011, 12:09 PM
Thanks Suvi
I cant use a template because each tip is unique and its number remains the same. Its just the total number if tips id like to have change on each page, as they grow.

Are the tips static images or text? If text, while this is a little clunky, you can always do something like this:



This is tip number
<!-- TemplateBeginEditable name="tipnumber" -->
27
<!-- TemplateEndEditable -->
of 60:
<!-- TemplateBeginEditable name="tip" -->
Remember to put those end brackets in, because otherwise your website won't work and you'll be sad.
<!-- TemplateEndEditable -->


So, with the 'of 60' outside of the editable region, and the actual tip # and then the tip itself in the editable regions, you can easily edit the total number of tips in the template while not changing the rest of the pages.

Oh, I should also mention that's the code that Dreamweaver gave me for my editable regions for my pages that use a template. I have no idea if that is how it goes everywhere else :)

bullant
05-14-2011, 12:55 PM
What about putting your tips in an array and looping through it or whatever.

The total tips "xx" will then simply be the value of the length property of the array.

nadley
05-14-2011, 01:19 PM
What about putting your tips in an array and looping through it or whatever.

The total tips "xx" will then simply be the value of the length property of the array.

ideally id like to just have a php form with one value in it say "xx" (the total number of tips), i could then manually ajust it each time i add a tip and then just look up the total number (in that form) on each page.

Then in my page put my html like this

<span style="font-size: 10px"><em>Tip 30/[xx insert wonderful code that looks up my form ...here] (more available to premium members)</em></span>

but in new to html so i have no idea how to do this

bullant
05-14-2011, 01:38 PM
Without seeing your actual code where you store the tips, I have only a vague idea of what you are trying to do.

But anyway, even if using php, I would think you could put your tips in a php array (if using a database is over-kill) in a php include (http://php.net/manual/en/function.include.php) file. You could then store the length of the array (got by using count() (http://au.php.net/manual/en/function.count.php)) in either a variable, session variable or constant and use it wherever you need to display the total number of tips.

Whenever you added or removed tips from the array, the length of the updated array would be got automatically using count().



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum