Linking to Data for Pages (pricing) in Layman's Terms
I have prices coded in 2 places on our site for the product pages. For example:
<td class="tablecelg" >$139</td>
and
<input type="image" class="i" onclick="addtocart('xyz description','paymentmethod','139','xyz')" value="Add To Cart" src="images/addtocart.png" />
PLUS There are 2 other pages where the product is listed same as this:
<td class="tablecelg" >$139</td>
What I'd like to do is have either a spreadsheet or a webpage where the prices could be updated on all 3 pages and the totals for the price 139 in the example above would be automatically updated. Basically a CMS.
hmm well this appears to be really basic php stuff. One way of accomplishing this is to create one php file that stores the price of the products in a variable then refer to that variable name on each page
Say you have prices.php to store your prices with this code
PHP Code:
<?php $xyz_price = 139; ?>
Then on each web page you add this code near the top
PHP Code:
<?php include_once("prices.php"); ?>
And wherever you have 139 on the page replace with this code
PHP Code:
<?php echo $xyz_price; ?>
Not a CMS but you only have to edit one file in a text editor instead of all your files. Your just using an include on each page so that the $xyz_price variable can be found in each page.
Hope this is what you mean, because a cms is alot more complex.
If i misunderstood then I apologize and I blame it on noise distractions
<input type="image" class="i" onclick="addtocart('xyz description','paymentmethod','139','xyz')" value="Add To Cart" src="images/addtocart.png" />
Just a quick tip, never rely on the prices set in the users browser for your order. EG When totalling up the order total on the users screen in J.script, do not use this value and then send it to the server - doing that can create massive problems (eg a user could order a $600 product for $1).
Sure, for displaying totals to the user locally its fine but ALWAYS calculate the actual numbers on the server from data held on the server.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
Truffle it worked even with the javascript. So how complicated would it be to make a CMS where there could be a form for the customer which would post into a database or something to update the prices.php page?
Ok no probs. Yeah well there is no charge till the order is confirmed and we haven't had any issues so far with price manipulation. Our customers aren't developers I guess : ).
I found a poor man's way to have our clients update pricing and it would just involve me to copy and paste their updates into that pricing.php page and upload... 30 seconds of work. Still beats the heck out of manually updating 26 product pages : ).
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
HOW CAN?
Are you trying to derail this thread?
IE has a bug. If your cursor is in a text box and you hit return, the submit button is not sent. If you click it with the mouse, it is. This is why you should ALWAYS test for another form field instead.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
Ok no probs. Yeah well there is no charge till the order is confirmed and we haven't had any issues so far with price manipulation. Our customers aren't developers I guess : ).
Don't be reliant on that. Someone will stumble on any weakness you have and it will be abused. Thats a fact. It's just the way the web works. If people can get something cheap they will do anything.
Quote:
Originally Posted by johnwboyd
I found a poor man's way to have our clients update pricing and it would just involve me to copy and paste their updates into that pricing.php page and upload... 30 seconds of work. Still beats the heck out of manually updating 26 product pages : ).
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
No worries. I appreciate your concern but we're not charging them till we confirm the order so if they're trying to scam up front we'll know already not to do business with them : ).
I have a question guys would it be possible to put a comma here:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
string number_format ( float $number [, int $decimals = 0 ] )
string number_format ( float $number , int $decimals = 0 , string $dec_point = '.' , string $thousands_sep = ',' )
This function accepts either one, two, or four parameters (not three):
If only one parameter is given, number will be formatted without decimals, but with a comma (",") between every group of thousands.
If two parameters are given, number will be formatted with decimals decimals with a dot (".") in front, and a comma (",") between every group of thousands.
If all four parameters are given, number will be formatted with decimals decimals, dec_point instead of a dot (".") before the decimals and thousands_sep instead of a comma (",") between every group of thousands.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.
Oops, Sorry I've completely misunderstood you (That'll teach me for replying straight after getting up eh?)..
To put a comma here:
$Product = 1,500;
Just change it to a string:
$Product = '1,500';
Note that you won't be able to do any calculations on it though as far as I'm aware (I may well be wrong on this though). However using str_replace to strip out the comma prior to calcs will allow you to use it.
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value.