473,503 Members | 1,772 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 1480
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,$BrakeOil,$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
10998
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...
2
3571
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...
2
1665
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...
8
3369
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...
11
3126
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...
5
3606
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...
1
1786
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...
3
1507
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...
1
1311
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...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7076
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...
0
7323
jinu1996
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...
1
6984
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...
0
7453
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...
0
4670
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...
0
3162
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...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
732
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.