Forum Moderators: open
More intersting: those prices are in 3 different currencies.
It would be great to change 1 value and have those updated in pages.
Any ideas?
Here's what a snippet of the code might look like, just to get an idea...
// Imagine the prices have already been set to $prices[]
// Also imagine $page already contains most of the code for your page
$page .= '<ul>';
foreach ($prices as $p) {
$page .= '<li>Item 1:$'.$p.'</li>'; }
$page .= '</ul></body></html>';
// imagine $filename is the file we want to write to
$handle=fopen($filename);
fwrite($handle, $page);
fclose($handle);
If you're not familiar with an appropriate language, you'll need to take some tutorials to get started, because there's way more to learn than I could go over here.
Oh, and BTW, I haven't really used fwrite myself so my syntax is probably a little off.
For Busy: I already have my html page and can't subsitute that. So the resulting file is not an option to me since I can't throw away my current pages. If didn't get it please explain further, and thank you!
Includes would be the quickest way to do it. Don't use an include for each item, but use an include for the whole list if you can manage it. That way you can stick the include on every page where you want that list of products, and the only thing you'll have to update will be the one include file.
But really, if you're starting to work with sites that need updating a lot, you'll save yourself a lot of headaches if you set aside a weekend and get down the basics of a good server-side scripting language(like PHP) The time you save in the longrun will be well worth it, and you'll be able to do a lot more with your websites, especially if you learn MySQL at the same time.
If you decide to use javascript instead, keep in mind that there will be a relatively small minority of people out there that have javascript turned off or their browsers don't support it, so make sure that the page still makes sense for those guys, even if it just shows a message saying "To view prices, you will need javascript enabled." I think this can be easily done with the NOSCRIPT tag.
About javascript non supported: does IE 4.x and higher and firefox support it right? In that case that's a 97% of people in my case but I'm not sure about what browsers does. Can someone confir or deny my guessing?
vincevincevince:
Can you explain more detailed that? I don't know how to do that but sounds good!
IMO, 5% is a number I could live with for one of my sites, but is too much if the site is for a client.