Problema al insertar numeros con separacion de punto y coma
Publicado por Javier Ojeda (3 intervenciones) el 17/03/2018 00:53:43
Buenas , espero me puedan ayudar mi problema es el siguiente tengo un pequeño sistemita que la persona registra un monto pero el problema que mysql lo toma entero al momento de aplicar una suma en la tabla solo me toma el monto antes del punto ejemplo si ingreso 20.000.000 solo me toma en la suma total 20 no toma en cuantas punto me pueden ayudar?
aca el codigo donde inserto el registro
aca donde muestro el total y historial de los ingresos
aca el codigo donde inserto el registro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php require_once('../Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO ingreso (monto, tipo, fecha, detalle) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['monto'], "text"),
GetSQLValueString($_POST['tipo'], "text"),
GetSQLValueString($_POST['fecha'], "text"),
GetSQLValueString($_POST['detalle'], "text"));
mysql_select_db($database_localhost, $localhost);
$Result1 = mysql_query($insertSQL, $localhost) or die(mysql_error());
$insertGoTo = "load.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_localhost, $localhost);
$query_tipo = "SELECT * FROM tipo ORDER BY id DESC";
$tipo = mysql_query($query_tipo, $localhost) or die(mysql_error());
$row_tipo = mysql_fetch_assoc($tipo);
$totalRows_tipo = mysql_num_rows($tipo);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>..:: Bancario ::..</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.min.js"></script>
<script>
$( document ).ready(function() {
$('#fecha').datepicker();
});
</script>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
.Estilo1 {
font-size: 12px;
font-weight: bold;
}
-->
</style></head>
<body>
<p class="Estilo1">Ingresar Activo</p>
<p class="Estilo1"> </p>
<div align="center">
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<br />
<table width="727" height="97" border="0">
<tr>
<td width="378"><div class="form-group">
<!-- Monto-->
<label for="monto" class="control-label">Monto de la Transaccion</label>
<input type="text" class="form-control" id="monto" name="monto" placeholder="Ingrese monto de la Transaccion en BsF" required="required" />
</div></td>
<td width="52"> </td>
<td width="283"><div class="form-group">
<!-- Titulo-->
<label for="tipo" class="control-label">Tipo de Transaccion</label>
<select name="tipo" class="form-control" id="tipo">
<?php
do {
?>
<option value="<?php echo $row_tipo['nombre']?>"<?php if (!(strcmp($row_tipo['nombre'], $row_tipo['nombre']))) {echo "selected=\"selected\"";} ?>><?php echo $row_tipo['nombre']?></option>
<?php
} while ($row_tipo = mysql_fetch_assoc($tipo));
$rows = mysql_num_rows($tipo);
if($rows > 0) {
mysql_data_seek($tipo, 0);
$row_tipo = mysql_fetch_assoc($tipo);
}
?>
<select name="prioridad" class="form-control" id="prioridad">
</select>
</div>
</p> </td>
</tr>
<tr>
<td><div class="form-group">
<!-- Detalle-->
<label for="detalle" class="control-label">Detalle de la Transaccion</label>
<input type="text" class="form-control" id="detalle" name="detalle" placeholder="Ingrese Detalle de la Transaccion para Referencia" required="required" />
</div></td>
<td> </td>
<td><div class="form-group">
<!-- Fecha -->
<label for="fecha" class="control-label">Fecha de Transaccion</label>
<input type="text" class="form-control" id="fecha" name="fecha" required="required" /></td>
</tr>
</table>
<p> </p>
<table width="246" border="0">
<tr>
<td><button type="submit" class="btn btn-primary" id="enviar" name="enviar">Ingresar</button></td>
<td><button type="button" class="btn btn-danger" id="regresar" name="regresar" onclick="location.href='index.php'">Cancelar</button></td>
</tr>
</table>
<p> </p>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</div>
<p align="center" class="Estilo1"> </p>
</body>
</html>
<?php
mysql_free_result($tipo);
?>
aca donde muestro el total y historial de los ingresos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php require_once('../Connections/localhost.php'); ?>
<?php
$suma = 0;
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_listar = 25;
$pageNum_listar = 0;
if (isset($_GET['pageNum_listar'])) {
$pageNum_listar = $_GET['pageNum_listar'];
}
$startRow_listar = $pageNum_listar * $maxRows_listar;
mysql_select_db($database_localhost, $localhost);
$query_listar = "SELECT * FROM ingreso";
$query_limit_listar = sprintf("%s LIMIT %d, %d", $query_listar, $startRow_listar, $maxRows_listar);
$listar = mysql_query($query_limit_listar, $localhost) or die(mysql_error());
$row_listar = mysql_fetch_assoc($listar);
if (isset($_GET['totalRows_listar'])) {
$totalRows_listar = $_GET['totalRows_listar'];
} else {
$all_listar = mysql_query($query_listar);
$totalRows_listar = mysql_num_rows($all_listar);
}
$totalPages_listar = ceil($totalRows_listar/$maxRows_listar)-1;
$queryString_listar = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_listar") == false &&
stristr($param, "totalRows_listar") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_listar = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_listar = sprintf("&totalRows_listar=%d%s", $totalRows_listar, $queryString_listar);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>..:: Bancario ::..</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.min.js"></script>
<style type="text/css">
<!--
body,td,th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
.Estilo1 {
font-size: 12px;
font-weight: bold;
}
-->
</style></head>
<body>
<p class="Estilo1">Manu Ingresos</p>
<p class="Estilo1"> </p>
<p class="Estilo1"><button type="button" class="btn btn-primary" id="agregar" name="agregar" onclick="location.href='ingresar.php'">Agregar Activo</button></p>
<p class="Estilo1"> </p>
<div align="center"><br />
<?php if ($totalRows_listar > 0) { // Show if recordset not empty ?>
<table width="958" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#A6DBFF">
<td width="93"><strong>N° Movimiento</strong></td>
<td width="152" height="25"><strong>Monto</strong></td>
<td width="157"><strong>Tipo</strong></td>
<td width="221"><strong>Detalle</strong></td>
<td width="126"><strong>Fecha</strong></td>
<td width="109"><strong>Modificar</strong></td>
<td width="100"><strong>Eliminar</strong></td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_listar['id']; ?></td>
<td height="33" bgcolor="#80FF80"><strong><?php echo $row_listar['monto']; ?></strong></td>
<td><?php echo $row_listar['tipo']; ?></td>
<td><?php echo $row_listar['detalle']; ?></td>
<td><?php echo $row_listar['fecha']; ?></td>
<td><a href="editar.php?id=<?php echo $row_listar['id']; ?>">
<button type="button" class="btn btn-warning btn-xs" id="modificar" name="modificar">Modificar</button>
</a></td>
<td><a href="eliminar.php?id=<?php echo $row_listar['id']; ?>">
<button type="button" class=" btn btn-danger btn-xs" id="eliminar" name="eliminar">Eliminar</button>
</a></td>
</tr>
<?php } while ($row_listar = mysql_fetch_assoc($listar)); ?>
</table>
<br />
<table border="0">
<tr>
<td><?php if ($pageNum_listar > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_listar=%d%s", $currentPage, 0, $queryString_listar); ?>"><img src="../imagenes/First.gif" border="0" /></a>
<?php } // Show if not first page ?>
</td>
<td><?php if ($pageNum_listar > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_listar=%d%s", $currentPage, max(0, $pageNum_listar - 1), $queryString_listar); ?>"><img src="../imagenes/Previous.gif" border="0" /></a>
<?php } // Show if not first page ?>
</td>
<td><?php if ($pageNum_listar < $totalPages_listar) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_listar=%d%s", $currentPage, min($totalPages_listar, $pageNum_listar + 1), $queryString_listar); ?>"><img src="../imagenes/Next.gif" border="0" /></a>
<?php } // Show if not last page ?>
</td>
<td><?php if ($pageNum_listar < $totalPages_listar) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_listar=%d%s", $currentPage, $totalPages_listar, $queryString_listar); ?>"><img src="../imagenes/Last.gif" border="0" /></a>
<?php } // Show if not last page ?>
</td>
</tr>
</table>
<?php } // Show if recordset not empty ?>
<br />
</div>
<?php if ($totalRows_listar == 0) { // Show if recordset empty ?>
<div class="alert alert-danger">No se encontro Movimientos</div>
<?php } // Show if recordset empty ?>
<p class="Estilo1">Total Ingresos </p>
</body>
</html>
<?php
mysql_free_result($listar);
?>
Valora esta pregunta


0