Hi,
I am looking for a good function to check if a entered value is
a money value - meaning it's a decimal with no more then 2 digits after the point.
Thanks,
Stefan 7 5181
I noticed that Message-ID:
<e2**************************@posting.google.com > from Stefan Richter
contained the following: I am looking for a good function to check if a entered value is a money value - meaning it's a decimal with no more then 2 digits after the point.
Check user notes. http://php.net/manual/en/function.eregi.php
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
On 14 Feb 2005 05:13:03 -0800, Do****@gmx.de (Stefan Richter) wrote: I am looking for a good function to check if a entered value is a money value - meaning it's a decimal with no more then 2 digits after the point.
Something along the lines of:
preg_match('/^\d+(?:\.\d\d?)$/', $money_value)
Do you want to allow it to be preceded by a currency symbol? How about commas
for thousands separators, or allowing mainland-European-style separators
(points for thousand separators, comma for decimal e.g. 1.000,99)?
The above would be OK if all you want is "digits followed optionally by [dot
plus one or two digits]".
--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
I assume you are talking about this function:
function check_price($price)
{
$data=split('[.]',$price);
if ( count($data) != 2 )
return "false";
if ( ctype_digit($data[0]) && ctype_digit($data[1]) && $data[0][0]
!= '0')
return "true";
else
return "false";
}
However, there are two problems:
1. I can't find this ctype_digit function in my php reference, so I
assume it doesn't exist.
2. How can I switch from german to english number format???
I thought number_format($money,2,".",",") would do it,
however, it seems that this chops of existing values after the comma /
dot.
???
Thanks,
Stefan
Hi, I want to go create a table with a textfield where the user can
enter an amount for a certain dynamically created article coming from
the database.
Later, I want to calculate the whole price and so on.
It works nicely to create my multi dimensional array,
however, it does not work to save the values coming from the form to
calculate the price.
What's wrong???
<form name="shop" method="post" action="index.php">
$articleTable = array();
while ($row = mysql_fetch_array($result)) {
$articleNr= $row["articleNr"];
$name= $row["name"];
$picName= $row["picName"];
$price = $row["price"];
$amount="";
$articleRow = array(
"articleNr" => $articleNr,
"name" => $name,
"picName" => $bildName,
"price " => $price ,
"amount" => $amount
);
array_push($articleTable , $articleRow );
}
foreach($articleTable as $article) {
?>
<input type="text" name="article[amount]" size="2" maxlength="2"
value="<? $article[amount] ?>"></td>
}
<?
}
?>
</form>
Thanks for your reply Andy.
-------
Well, first of all it needs to be able to be saved my mysql.
Can mysql understand thousands seperators?
If not, I would need a function to take out these seperators.
About . vs ,:
Well, this function is for Germany,
so I would need it the other way round,
but the best was if it would except both of course.
And no, I don't need a currency symbol, as I am always using euros so
I am not saving that in the database.
Thanks,
Stefan
I noticed that Message-ID:
<e2**************************@posting.google.com > from Stefan Richter
contained the following: Later, I want to calculate the whole price and so on. It works nicely to create my multi dimensional array, however, it does not work to save the values coming from the form to calculate the price. What's wrong???
There is no code there which does that. And if you already have an
array called $row why change it to an array called $articleRow It seems
identical apart from the variable $bildName which appears from nowhere.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Geoff Berrow <bl******@ckdog.co.uk> wrote in message news:<cb********************************@4ax.com>. .. I noticed that Message-ID: <e2**************************@posting.google.com > from Stefan Richter contained the following:
Later, I want to calculate the whole price and so on. It works nicely to create my multi dimensional array, however, it does not work to save the values coming from the form to calculate the price. What's wrong???
There is no code there which does that. And if you already have an array called $row why change it to an array called $articleRow It seems identical apart from the variable $bildName which appears from nowhere.
Sorry, I forgot to change that variable name to english - it's
picname,
and yes basically they are identically -
Okay, that was stupid -
Anyway - All I want is an array that contains the data coming from the
databse
AND also the amount of each article coming from the form the user
fills.
I was able to make an array containing the amount of each article,
and I got the array coming from the database -
Now what I just don't like is that I don't have any evidence that
row[0] of the first array is identically to row[0] to my amount array
-
If I had all in one array, I could easily go through the array and
work with it - no matter if it was sorted or not.
Stefan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Batista, Facundo |
last post by:
Here I send it.
Suggestions and all kinds of recomendations are more than welcomed.
If it all goes ok, it'll be a PEP when I finish writing the code.
Thank you.
.. Facundo
|
by: shank |
last post by:
I'm getting the following error...
Microsoft OLE DB Provider for SQL Server error '80040e07'
Disallowed implicit conversion from data type varchar to data type money,
table 'wsOrders', column...
|
by: teddysnips |
last post by:
In the script below is the DDL to create some tables and a UDF.
What I'm interested in is the UDF at the end. Specifically, these few
lines:
--CLOSE OTRate
--DEALLOCATE OTRate
ELSE --...
|
by: grist2mill |
last post by:
I want to create a standard tool bar that appears on all pages that is
a control. The toolbar has a button 'New'. What I wolud like when the
user clicks on 'New' depends on the page they are on. I...
|
by: tdick |
last post by:
Does anyone know sql of the PV function in Access? (same function in
Excel)
In access the inputs are PV («rate», «nper», «pmt», «fv»,
«due») where rate = discount rate, nper = number of...
| |
by: Paul |
last post by:
Anyone have code that emulates the Nz function in Microsoft Access?
In Access it is:
Nz(Value as variant, Optional ValueIfNull as Variant) as Variant
|
by: Xiaoshen Li |
last post by:
Dear Sir,
I am a little puzzled about a function returning a class object, for
example, suppose I hava a class Money and a method:
Money lastYear(Money aMoney)
{
Money tempMoney;
......
|
by: souporpower |
last post by:
Hello All
I am trying to activate a link using Jquery. Here is my code;
<html>
<head>
<script type="text/javascript" src="../../resources/js/
jquery-1.2.6.js"</script>
<script...
|
by: compdude |
last post by:
Hello everyone,
i need some help on my programming in python
i am trying to make a program that can ask for information and document it on a excel spreadsheet. Im a beginner programmer and i am...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |