close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

PHP/MySQLi recordset search not working with decimal amounts?

Thread began 4/12/2017 7:42 pm by Nathon Jones Web Design | Last modified 4/13/2017 2:25 pm by Ray Borduin | 276 views | 7 replies |

Nathon Jones Web Design

PHP/MySQLi recordset search not working with decimal amounts?

I have a decimal field in my database for storing currency values. I have a drop-down select form which searches this field (Ticket Price) depending on the value selected by the user:
http://www.dreamcargalaxy.com/car-competition.php

This drop down is populated by results from the table, grouped by value, however when you select any of the decimal values - £3.50 or £4.50 - the search isn't working.

In the database table the values are stored as 3.5 and 4.5.

I tried changing the option value from

<option value="<?php echo($rsTICKETS->getColumnVal("dreamcarTICKETPRICE")); ?>">



to...

<option value="<?php echo number_format($rsTICKETS->getColumnVal("dreamcarTICKETPRICE"),2); ?>">



....to try to force the decimal value, but that hasn't changed it. What am I doing wrong?

Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

You aren't doing anything wrong. Number fields off all types remove placeholders like this behind the decimal in the database. You can simply add it back and format it to two decimals when you display it.

Sign in to reply to this post

Nathon Jones Web Design

Add it back? I've tried doing that with number_format but it still doesn't search correctly.
If the values in the drop down are coming from the database, and those values are being used to search the database, why isn't it returning any results when selecting any of the decimal values?

Thank you
NJ

Sign in to reply to this post

Ray BorduinWebAssist

Are you doing a number type search? I'd have to look at the page.

Sign in to reply to this post

Nathon Jones Web Design

It's detailed in the original post.

It's the ticket price drop-down select on this page:
http://www.dreamcargalaxy.com/car-competition.php

It's a jump menu that is populated by a recordset which groups values from the field it's querying so I have no idea why it's not picking up decimal values.

Thank you Ray
NJ

Sign in to reply to this post

Ray BorduinWebAssist

What is not working with it? The list seems to filter properly when I try. What exactly is the problem you are having?

Sign in to reply to this post

Nathon Jones Web Design

Try selecting either £3.50 or £4.50.
What you get is items whose ticket price is £3.00 and £4.00 respectively. All of the other selections work.

Sign in to reply to this post

Ray BorduinWebAssist

You have done your search with recordset parameters and defined your parameter type as "integer"... it needs to be "floating point number" to allow decimals.

To fix the problem, change the "i" on line 58 to "d"

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...