473,657 Members | 2,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to call decimal values from sql into a table

5 New Member
the values in my sql is 1.200... but when i cal it into table it become 1 only..

how i call the data
Expand|Select|Wrap|Line Numbers
  1. {
  2. <?php
  3.         while($row = mysql_fetch_array($result)) {
  4.             $id = $row["id"];
  5.             $AddCar = $row["AddCar"];
  6.             $AddPlateNo = $row["AddPlateNo"];
  7.             $AddPackage = $row["AddPackage"];
  8.             $AddMileage = $row["AddMileage"];
  9.             $AddAge = $row["AddAge"];
  10.             $Date = $row["Date"];
  11.             $Month = $row["Month"];
  12.             $Year = $row["Year"];
  13.             $Time = $row["Time"];
  14.  
  15.         $all=mysql_query("SELECT * FROM car WHERE id='$id'");
  16.         $row2=mysql_fetch_array($all);
  17.             $EngineOil = $row2["EngineOil"];
  18.             $BrakeOil = $row2["BrakeOil"];
  19.             $GearOil = $row2["GearOil"];
  20.             $Coolant = $row2["Coolant"];
  21.             $AirFilter = $row2["AirFilter"];
  22.             $Container = $row2["Container"];
  23.     ?>
  24.     <tr>
  25.         <td><?php echo $AddPlateNo; ?> </td>
  26.         <td><?php echo $AddCar; ?> <br></td>
  27.         <td><?php echo $AddPackage; ?></td>
  28.         <td><?php echo $AddMileage; ?></td>
  29.         <td><?php echo $AddAge; ?></td>
  30.         <td><?php echo "$Date/$Month/$Year / $Time"; ?> <br></td>
  31.         <td><?php echo $EngineOil;?></td>
  32.         <td><?php echo $BrakeOil;?></td>
  33.         <td><?php echo $BrakeOil;?></td>
  34.         <td><?php echo $GearOil;?></td>
  35.         <td><?php echo $Coolant;?></td>
  36.         <td><?php echo $AirFilter;?></td>
  37.         <td><?php echo $Container;?></td>
  38.         <td><a href="updateCar.php?id=<?php echo $id; ?>">Update</a>/<a href="buang.php?id=<?php echo $id; ?>">Delete</a></td>
  39.     </tr>
  40. <?php
  41. }
Nov 27 '13 #1
7 1494
Exequiel
288 Contributor
what data type did you used for the field of where the data 1.200 came from? because if it is in varchar for me your code is right. you can visit this link.
http://us2.php.net/floatval
Nov 28 '13 #2
aizad
5 New Member
the data type is decimal
Nov 28 '13 #3
aizad
5 New Member
and it came from $EngineOil,$Bra keOil,$GearOil, $Coolant...the data type in sql/xampp is decimal 5,3....the data in the database is for example is 1.200 but when i call it into the table it become 1 only..can give me your email..i'll send you the pic..pls help..tq
Nov 28 '13 #4
Exequiel
288 Contributor
if your data type is decimal, in your insertion the data that being saved is always be a whole number, if you want to insert to your table a whole number and a float you can use varchar or double,
Nov 28 '13 #5
aizad
5 New Member
still the same..i have change i into varchar..
is there anything wrong here? because the value saved in sql is decimal number.

$EngineOil = $row2["EngineOil"];

<td><?php echo $EngineOil;?></td>
Nov 28 '13 #6
aizad
5 New Member
thank you very much..i found my mistake. tq so much
Nov 28 '13 #7
Exequiel
288 Contributor
your always welcome. . :D
Nov 28 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
11004
by: KathyB | last post by:
I need this function to accept decimal values (e.g., 2.5 ok, not just whole numbers between 1 and 5). I can't find this answer... thanks, kat *************************** function ValidateSave(formRef,fieldName,min,max) {
2
3592
by: Carl G | last post by:
I am storing a 0.000 a System.Decimal in a DataRow. On retrieval the value is only 0 without the three decimal places. It looks like the Get property returns System.Decimal.Zero, but why???? I can't figure out why the design is so that the DataRow "alters" the value entered. In my application a decimal column in a row of a specific table has a fix number of decimal places according to certain premises. The
2
1675
by: Chuck Insight | last post by:
Hi All, I designed an input query as the basis of a form. Some fields (like for pennies) are numbers that I formatted as currency and specified as 2 decimal places. However, it appears to round down anything under 50¢, which then displays as $0.00 and appears to round up anything over 51¢, which then displays as $1.00 How can I get these to show up "Properly" in the form? Thanks very much, Chuck
8
3384
by: Ahmad A. Rahman | last post by:
Hi all, I have a problem constructing a regular expression using .net. I have a string, separated with comma, and I want to group the string together but, I failed to group a numeric character with decimal values. Example string : 1, 2.3, "two"," three" So, I want to group this string into 4 groups (1), (2.3), (two) and (three)
11
3146
by: irkahs | last post by:
Hello all, I ask this question because I searched and did not find anything that related to this query. My apologies if this is a mistake. Please see the following code. I am using 2 ASP pages. One to fill up a decimal value (it is actually the unit price of something) and the other to receive and process it. The value in the first page can be entered by the user as a whole number OR as a number with decimal places. Ex. 2345.88...
5
3616
by: Angus | last post by:
Hello I have an unsigned char and I want to convert the individual array values into hex and copy to a std::string. The array does not always hold 14 values - but I do know the length of the data - obviously up to 14 chars. An example is an array of six items with decimal values: 0, 10, 228, 164, 72, 11. I want to convert these values to hex and copy to a
1
1807
by: iquttaineh | last post by:
Hi, I have a stored procedure that executed in SQL Server 2000 that returns a decimal SUM value, the stored procedure executed successfully in Query Analyzer and returns the correct value, but when calling it from ASP.Net (VB) Page it always returns ZERO !!! I'm sure that my VB.net code is true because i used it before successfully. my stored procedure code is: ...
3
1514
by: RajeshVoruganti | last post by:
When i am adding the two decimal values using with java script var first = 0.1; var second = 0.2; var tot = parseFloat(first) + parseFloat(second); i am expecting result as : 0.3 But it is giving result as : 0.30000000000000004
1
1318
by: Sandosh kumar | last post by:
i have two web forms... web form 1 has two drop down list box.. by selection items in this drop down lists ..& clicking next button.. i must call required specific table from ms-access in web form 2..based on items selected in web form 1.. since i have many tables in it..how could i call required table in web form 2.. based on selection of web form 1..?? can u please give any coding for this??
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
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 we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.