Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Data Field With Currency Not Sorting Accurately


I have a datatable with a varchar field know as "price". At this time I have 3 rows in it; they are as follows: $ 18,500 $19,500 and $ 9,500. The problem is that when I try to sort in either ascending or descending order; it does not sort right. I know the problem lies in the $ 9,500, because I added a zero in front of the 9,500 (like this: $ 09,500) and it sorted fine. At first I thought it may have had something to do with the dollar sign, but it didn't because I removed and tested it without dollar sign and still had the same problem.

What I want to know is, how I can make datatable sort accurately with putting a zero in front of the 9,500. I tried to use a CSS style to cover up the zero, but when I did that, datatable still would not sort the right way. MySQL code in my web page is accurate, because you can take the $ 9,500 and add a 5 digit number and it works fine.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Sorting Data
Im displaying data from a mysql query that displays a Player, email, id etc.. and I have links that sort the data by player, email, id etc... But Ive seen websites where you click sort and it will sort the data by that and if you click it again it will sort that data this time in descending order.

How am I able to have link that will sort the data normally and descending order?

Data Sorting
I have a database table that has these fields: id (auto increment), date, message and what I wanted to do is sort the messages in order starting from the latest messages. I then wanted to sort the messages and only show 5 messages per page. I managed to do all this but now I also want all the messages with the SAME DATE (but different times) to be shown in the same table. for example: Code:

Sorting Data Help
I know this should be fairly easy, but I am still very new at this. Ok, I am trying to pull data from my database and sort it. I want it to sort it by using field one sorting alphabetically, but only pulling up results from field two that has a specific name. I am not explaining this well sorry. I'll give you the code that I am trying and it's not working because I know I am not doing it right.

$result = mysql_query("select * from items where itemName Like'A%' and WHERE field2='value' order by itemName asc");

Sorting Data
I want my web site to be as dynamic as possible (hence the reason for trying to master php) but the knowledge I have at the moment will not quite stretch to doing the following:

I want to have the height attribute of an image to be controlled by data in a database table. The table will hold the numeric test result that pupils score when they take a test on my web based tutorial. The image is a column, the larger the score, the larger the column. I would like to know: Code:

Sorting Data
i'm creating a page that has pagination.  but the data just gets listed on and on .  is it possible for a 5 data to go across in a single row, then break, and another 5 data across again, like in this image: Code:

Sorting / Splitting Data
I have some member data in a field in a MySQL table that I want to work with in PHP and output to HTML. Let's say the data in one cell of a table looks something like this:

Joe Smith:user@aol.com
Nancy Beck
Greg Jones
Sarah Lister:sarahb@yahoo.com

Now, I know that I can use 'explode' and the character together to put each of those values in an array in PHP so I have something to loop and be able to output the names in a list. But I still have the ":" delimiter within those results, and I want to be able to link the email addresses to their respective names as I run the loop. Is there an easy way in PHP to do this?

Sorting Data - Whats The Best Way?
I have a number of members stored in my database, and i would like to create a page to allow people to browse through the members and see certian bits of information.

I would like this page to be dynamically ordered (sorted) by the date the information was last updated, thereby keeping the most up to date information at the front, and penalising those that dont update often.

I am thinking of simply adding a field in my database, and inserting a gregorian timestamp (based on the servers current date) everytime a member updates the info.

Firstly, is this the best way of keeping track of updates ?

And, how would i go about ordering my data by this particular data?..... does php have an "order by" function?

Sorting Display Data
Here's the situation:

On our Golf Leaderboard, when scores are submitted, the actual numerical scores are to be sorted from lowest numeric value to the highest, while the 'over/under par' values are sorted from highest to lowest. This works just fine when only TWO scores are submitted, and displayed.

Anything over 3 player scores, it reverses the sorting of the data stated above.

Here's the PHP file: (I consider this script 'short' - I hope it falls with the parameters mentioned by the staff) Code:

Paginating And Data Sorting With Php/mySQL
I have a main menu full of information which is paginated 20 records per page. I'm trying to make the query so that the user can sort the data by links located at the top of the page.

"What's My Problem?" - It works, when I select the link it sorts by whatever I have selected as I want but...

The Problem - It only sorts one page and doesn't continue on, when I click page two the values are reset. This is a new operation to me so if anyone could offer a suggestion I'd appreciate it.

The Question - How do I sort paginated data and make it so the data stays sorted throughout the 20 or so pages?

Sorting Multiple XML Data By Date
I am making an RSS parser that takes multiple XML inputs in to an
array and then sorts them by their date value... and it 'almost'
works... I always lose the top value of the second rss feed to be
parsed... its pretty annoying as this is often the most recently
updated RSS item that is missing from my multi-feed...

usort($xmlreader_parsed_data, "rss_cmp");

which calls this function:

function rss_cmp($a, $b)
{
$a = strtotime($a->date);
$b = strtotime($b->date);

if ($a == $b) {
return 0;
}
return ($a $b) ? -1 : 1;
}

How Do I Get Image Data Into A Blob Field
I am trying to get image data into a mysql field (like a simple jpg). Does anyone have a quick tips on how to submit an image (through an html form) process via php and insert into a mysql blob field?

Pulling Data From The Last Field Of A Table
What is the command to view the last result in a table using a DB query?

Table Example
TABLE PEOPLE
>ID
>NAME
>POINTS

one thing, it cant be ORDER BY id DESC

If at all possible it has to be
SELECT * FROM people WHERE name=jon && id=**last id**

**last id** = Last id where the name jon was found.

Reverse Sending Data From Value Field
What I want is this. I have a page where I want to update information.
So lets say it is already:

Title - Milk
Category - Dairy
postDate - 9/18/2007

And I want to Change it to:
Title - Cheese
Category - Dairy
postDate - 9/18/2007


I want this page to display the information (before it is updated) in the edit field.

So right now I have this
<input name=title value="<?PHP echo $rows['deal_title'];?>"/>

What I am doing here, with the sql information excluded of course, is pull out the title of a row that was selected.

the information comes out but not well. One of the many input type "text" boxes are for inputting html links such as http://www.domain.com/ and the title would be used with html code as well (for visual formatting on the web page).

What ends up happening is when the information is first pulled from the database to fill in the values, after certain html characters (like > after <font...) the rest of information spills out of the text box and becomes uneditable because of this. Most of the code is also gone even though it is in the database.

Making A New EXIF Data Field...
Is there anyway with PHP to make a new EXIF data field in a JPG, like, for example, "Album"?

Reading MySQL Data In A Form Field
i am in the process of building an admin page for a site. Most of my site data is being held in MySQL and being pulled using PHP. The problem I have is while trying to build an Admin form to change data in MySQL, I want to have the data that is currently in the table be automatically put into the form field, so they can see what they are changing before they change it, or so if they do nothing it keeps the same data in it. My code is as follows:

How To Assign Data In A Table Field To A Variable
what exactly do i do to only retrieve information from a table and assign it to a variable? I don't want to manipulate the data in any way, just display it on the page.

Odd Problem: Data From Hidden Field Is Not Sent To Server...
Perhaps someone can figure this out - this is 'the process of my script'

I have a form whereby I can add multiple contacts to a single address.
There is only one firstname/lastname/telephone box - when the user
clicks the add button, I read the values from the form fields and
record them into a hidden text input field. This part works because
during debugging, I have converted the <input type=hidden> into a <input
type=text> to visably confirm my data is being copied into the 'hidden'
field.

Once the user has entered in one or more names, they can click another
button and submit the form for processing. My idea is that I would then
parse this hidden field server side...

I have a WAMPHP based server and as a test, I dump out my entire $_POST
(basically, the name and value in every INPUT tag).

My PHP script picks up the name of every input tag, including the hidden
field (like it should) but for some reason, the value that was written
to the hidden field is not passed to the server. Thus, for the PHP folk
reading this post, my hidden input field is called mylist and
$_POST['mylist'] exists, but its empty. Even though before processing,
I could visably see the input in the box (for debugging remember, I made
the input tag box a normal, unhidden one).

Here is what I have done to try and resolve:
- I have used both Mozilla 1.7.5 and IE6 - both provide same results -
my hidden field name gets passed, but not its value.

- I have created another hidden field and given it a default value ie I
have <input type="hidden" name="extraone" value="xyz"> and I get
$_POST['extraone']="xyz" passed to my php server, like I would expect -
however, the value of mylist is sent empty, even though it has data.

- I have even put in a javascript alert box just before the form is sent
to the server and can see the result in my (unhidden) box, and the same
value displayed in the javascript alert - but again, the value of the
mylist does not get sent to the server.

The only difference is that my hidden field (even if its displayed like
an ordinary text input box) does not post data written to form fields as
the result of a javascript function. Interestingly though, the server
does know about the input tag box since it does receive
$_POST['mylist'], it justs receives it empty.

What gives? If the form reads my input from one field, and writes it to
another field, then it should be sent to the server, true?

Also... my tags are all inside my <form></form> tag (which is proven by
double checking, and the fact that I do get the input tag box name sent
to my server).

Since I can see the data values in the box, it tells me my javascript is
doing what it should be doing - so I don't see any point in including my
javascript (though I have no problems doing so if someone requests
it). On the php server, I am using a simple phpinfo(); to check the
data is being received...

Cell Colour Based On Field Data
I have a mysql database and i am using php to display some field data in a table cell on a page. The field data is either 'failed' or 'passed', how can i make the cell colour change depending on the field data result?

Dont Want To Post Data If Row Field Is Empty
I dont want to post the $row ['thumbnail'] data in this string if the field is empty. Can someone help me out? ....

Return Data Breaking Input Field
My return data is: (I have nothing to do with how the og person choose to input this)

<font color="#800080">CASE</font>

and I am setting the value of a input text form field equal to that return

$input      = "<input type="text" name="queOpt". $i ."" value="". $this->_queArr[$i] ."" />";

im lost on how to fix this. addslashes doesnt make sense  - maybe it is the double quote thing

Display MySQL Data In Text Field
I have my site set up and am now working on the admin side. I have a page that lets me search my users then its linked to another page so I can edit the information.

I am attempting to get the code to display in my forms text boxes and text areas for updating. My problem is that I can't figure out how to get the data into my form for editing. I have a few different things but can't seem to figure this out.

Inserting Data Into A Table With Auto Increment In One Field
i have a table with several fileds in and with the first one being an auto increment field. I want to know what my SQL query should be when inserting data. Here's my current one: Code:

$SQL = mysql_query("INSERT INTO $usertable2 VALUES('$subject', '$newstext', '$date', '$usrname')";

The auto increment field is the first in the table and is called 'postid'. can someone give me the correct query please? also do i need the first entry in the table to be a blank one with just the postid entered at one?

Repeat Form Field Based On $_POST Data
i have a script that sets up a second page with multiple select boxes. the first script has a hidden field for the ID number, and a text input field for quantity. the second part of the script has a foreach loop that gets the info that goes with the ID number and then creates the select box next to it. for the most part it's all working correctly, but i don't know how to get the submitted "quantity" to repeat that ID number (and everything else). here is the initial form: Code:

RegExp - Removing Newline/carriage Return In Data Entry/form Field
I have a database generated calendar (written in php) which puts the contents of one of the fields in a javascript mouseover popup ( Carriage Driving World and select "Calendar" from top menu) which is populated by event organizers entering data via a form. Some people are putting line feeds in their EventDesc (field used for javascript mouseover popup) which screws up the javascript, where linefeeds/newlines aren't allowed.

The best solution I can think of is to either remove the linefeeds before the data gets stuffed into the database or when the data is presented to the javascript coding.

Here's where I need help. What RegExp string do I use to pull linefeeds/returns? Some of teh entries have more than one which needs removed.

Currency
is there any places where i can get som
currency data for free with php ?

Currency
i want to build a script that create US dollar to Philippines Peso.
example:

its auto:  1 USD = "Auto" PHP peso

currency script for this.

Currency
How do I output currency, as the zero on the end of the following value gets cut off:

e.g. £0.50

How do I add a zero, if a zero is expected to appear at the end of the value?

XML Currency Script
I have a table in my database that has 4 different currencies in it (I plan to add more when i have this xml update script done). This has 4 fields, 2 of which are code (eg USD, JPY) and multiplier (USD is taken as 1, and the rest are multiplied from there). Now, I would like to automatically update these currency multipliers using this xml data feed:

"http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"

The only problem is, i dont know where to start with it. Now if anyone could help me either create an array from this data (so i could use $cymulti['USD'] would equal the rate from the data feed that had the currency USD) or create individual variables such as $USD would equal the rate from the data feed for the currency USD).

Currency Formatting
i'm trying to format the output of a record in access, which i am
pulling from through php (odbc) and the formatting is set at 4 decimal
places, which i don't want. i want currency and no decimal places.
I was trying to use this example, but i have no bloody idea howo to use it.
or where to put it for that matter:

<?php

$number = 1234.56;

// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number)."
";
// USD 1,234.56

?>

Currency Symbols
I have a problem, we use a microsoft (mssql) product at work which stores currency symbols in the database.

Now when I retrieve these symbols from the database and try to echo them to the screen using php I just get a funny square box symbol instead of the actual currency symbol. Any idea on how I can get the symbols to show correctly?

Currency Rounding
I have the following output from a calculation: 211.5

I want to print this to screen as 211.50 (currency), but the round($value,2) doesn't force a rounding... is it possible?

Format Currency
I want to take a variable and make sure that I output to the browser in dollar format ie if I set $price=100. I want to make sure that $price appears as 100.00. in turn make sure that when $price=100.97 is outputted as 100.97

Format Currency With More Than 2 Decimals
I've tried to use both round and money_format but I can't seem to get what i what.

I have a shopping cart on my web site and I had the tax to the subtotal for calculating the total.

However the following problem arises when using round():
$13.2818
becomes $13.28 (should be $13.29)

$13.2772
becomes $13.28 (works fine)

Is there another function that will ALWAYS round up after X number of decimals?

Numeric Currency To Words
I have a program which calculates some transactions and giving the total as numbers. for eg. 1000.00. I want to display it in words also. Like (One thousand only)..

Clean Currency Input
I wrote the following function as a "cleaner" for a currency input:

function is_currency($v) {
//returns a string with only the numbers for a currency format
$v = str_replace("$", "", $v);
$regex = '/(?:([0-9]+)|.)/'
if(preg_match($regex, trim($v) ) ){
$v = $v + 0.00001;
if (is_float($v)) {
return round($v, 2);
}
}
else {
return 0;
}
}

I want users to be able to put in things like:
NZ$12.34
$12.34
12
12.3456
1,002.23
and it should always translate into a number with two decimals (e.g. 12.34
or 12.00)

I am sure that this is probably the clumsiest way ever to do this. How can
I improve this function?

PS despite numerous efforts I am still super weak on regular expressions. I
can only copy them and not write them myself.

Want Currency Converter In Php Code
i want to convert one country currency to another country currency in my shopping web site without redirecting to another site. can u suggest some idea to do this.

Authorised.NET + Multiple Currency
Has any one integrate Authorised.net with multiple Currency? Example : I want to make transaction for $10 . with different currency types.

Force 2 Decimal Places For Currency
How can I force a value to retain 2 decimal places (or atleast display them)? E.G. force $19.90 to be displayed as such, not $19.9

Language And Currency Changing Script ?
I am asking this on behalf of a friend who is - as I am - completely
ignorant of php. Almost.

He has CartWeaver shopping cart. The php version. He need to be able to
allow users to swap currency and language with a click, but still have
the cart connected to one single and the same data base.

He has been in touch with the developers, and their reply is that the
feature might be included in next version.

Question is: Can he in some way apply this in a way himself with some
link(s) to extra language and currency files? If so, how should it be
done? Are there any samples out there? (we have both searched the web
for a month - in vane).

How Do I Insert And Display Currency In PHP/MySQL?
I have a field in mysql which is a double and I trying to store say $5.00. I'm entering 5.00 but my select statements are returning 5, I need the .00 as well though.

PAYPAL Problem :- Not Adding The Shipping Amount If Currency Is CHF

I have come up with a problem with PAYPAL integration in my project.
I have choosed the currency as CHF (swiss frank).

I have posted amount and shipping amont properly.

But When It is going to paypal. It is showing only amount ( its not including the shipping amount)

This problem do not occur if i choose currency as USD or CAD or any other.

I have attached the screen shots.

Displaying Currency Exchange Rates On A Page For Product Price
i want to display the price of a product on my site in multiple
currencies that is constantly updated to keep in line with exchange
rate fluctuations can anyone tell me how i could get access to basic
exchange rate data automatically for my site? (just a few major
currencies)

Can A Field Communicate To A Server And Return Information To Another Field Without Retrieving The Whole Html Code Again?
I´ve got a sql table which has 3 fields.
Their relation to each other is like this example.

| CARS | YEAR | PRICE |
ford 2000
ford 2001
ford 2003
volkswagen 1999
volkswagen 2000

I am developing an ASP web page that modifies a specific registry.
So, it loads the information to some fields, but the user will be able
to change only the "PRICE" field.
I have to create two selects, one for "CARS" and other for "YEAR".
But the "YEAR" field will only contain the correspondent years for each
car the user selects. Example: selecting "ford" in the "CARS" <select>
box, only the years "2000", "2001", "2003" would be automatically
loaded in the "YEAR" <selec> box.
How could i implement it?

How To Update A Table's Field With Another Tables Field?
I need to take the state field from dt_profile table and update the dt_matchfinder with this state making sure the member_id field matches.

the problem is the dt_matchfinder table has null set for many of the state field but in the dt_profile each member ID has a specific state and I need the same to be true in the dt_matchfinder table.

Select Both Field Name And Field Value- Mysql ?
What function to use to select both field name and field value from a mysql table ?

Sorting...
I was trying to sort a multi-dimensional array with one dimension being the sorting criteria. I wanted to make it sort by an alternative one if the main one is equal on two entries.

However that doesn't work: it sorts properly according to the main criteria, but it won't sort according to the alternative one. I hope you understood what I'm trying to say, since I'm not a native English speaker. Here is my code:

Sorting By Word?
Okay, I am making a member database, and when I print it out I want it to display the list by rank. Unfortantly, I stored Rank as a word. I could make a sort function that would be quite extensive and probably take a long time to execute every time...


..Or, is there anyway I can specify in SQL: Put this on the top of the list if "rank='General'" and then next if "rank='Captain'", and so on? I think if this was possible it would take a lot less time to execute...

Or else I will probably have to redesign much of the site with numerical ranks instead. Thanks for any answers/advice.

Sorting Options
I have an array I would like to sort, but the sorting options that I have found are inadiquate. I need to do a case insensitive sort, that does not maintain the index correlation. My problem is I have some items in my array beginning with "a" and some with "A", and I want the sorting based strictly on the letter not the case, and then I have to be able to reference them in an order that maintains the sort.

Sorting Strings!
Hi

I need to read a .txt file and sort the value, highest firs, lowest last.

The .txt file contains the following info on a different row:
altavista:joe:5
yahoo:eric:2
disney:dis:4

the firs thing i did was reading the first line and split the code by ":" so that
echo $referrer[0] //would give altavista
echo $referrer[1] //would give joe
echo $referrer[2] //would give 5

I want to sort these lines on the numbers(highest first, lowest last) and print this in a table. How can i do this?
so what i would like in a table is this

<table>
<tr><td>
altavista</td><td>5</td></tr>
<tr><td>
disney</td><td>4</td></tr>
<tr><td>
yahoo</td><td>3</td></tr>
</table>


Is this possible anyway?


Copyright © 2005-08 www.BigResource.com, All rights reserved