Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/05/2010, 09:26
warbandit69
 
Fecha de Ingreso: diciembre-2008
Ubicación: http://www.solucionesrios.tk/
Mensajes: 413
Antigüedad: 15 años, 4 meses
Puntos: 19
Busqueda imprimir numero como string con php

imprimir numero como string con php

Hola foreros, tengo una duda, estoy exportando los datos de una tabla de la BD a excel, pero cuando exporto los números estos salen sin el primer 0, y necesito que salgan con el 0, les pego el codigo de la exportación para ver que me pueden ayudar, y gracias por adelantado.

Código PHP:

<?php require_once('../Connections/ternerita.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$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"];



if (!empty(
$_SERVER['QUERY_STRING'])) {
  
$params explode("&"$_SERVER['QUERY_STRING']);
  
$newParams = array();
  foreach (
$params as $param) {
    if (
stristr($param"pageNum_Recordset3") == false && 
        
stristr($param"totalRows_Recordset3") == false) {
      
array_push($newParams$param);
    }
  }
  if (
count($newParams) != 0) {
    
$queryString_Recordset3 "&" htmlentities(implode("&"$newParams));
  }
}

            
$prefijo_sql " SELECT * ";
            require_once(
'../Connections/ternerita.php'); 

            
$condiciones = array();
              if (!empty(
$_POST['nombre'])) {
                 
$condiciones[] = "nombre";
              }
              if (!empty(
$_POST['celular'])) {
                 
$condiciones[] = "celular";
              }
            if (!empty(
$_POST['PIN'])) {
                 
$condiciones[] = "PIN";
              }
            if (!empty(
$_POST['telefono'])) {
                 
$condiciones[] = "telefono";
              }
            if (!empty(
$_POST['direccion'])) {
                 
$condiciones[] = "direccion";
              }
            if (!empty(
$_POST['correo'])) {
                 
$condiciones[] = "correo";
              }
            if (!empty(
$_POST['sexo'])) {
                 
$condiciones[] = "sexo";
              }
            if (!empty(
$_POST['profesion'])) {
                 
$condiciones[] = "profesion";
              }
              if (
count($condiciones) > 0) {
                
$prefijo_sql " SELECT " implode","$condiciones );
              } else {
                  
$prefijo_sql " SELECT * ";
              }     
            
mysql_select_db($database_ternerita$ternerita);
$query_Recordset1 $prefijo_sql." FROM suscriptor ORDER BY id_ususario ASC ";
$Recordset1 mysql_query($query_Recordset1$ternerita) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);

header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=reporte.xls");

?>
<table width="200" border="1">
  <tr>
    <?php if (!empty($_POST['nombre'])) { ?><td align="center"><strong>NOMBRE</strong></td> 
    <?php }?>
    <?php if (!empty($_POST['celular'])) {?> <td align="center"><strong>CELULAR</strong></td> 
    <?php }?>
    <?php if (!empty($_POST['PIN'])) {?> <td align="center"><strong>PIN</strong></td> 
    <?php }?>
    <?php if (!empty($_POST['telefono'])) {?> <td align="center"><strong>TELEFONO</strong></td> 
    <?php }?>
    <?php if (!empty($_POST['direccion'])) {?> <td align="center"><strong>DIRECCION</strong></td> 
    <?php }?>
    <?php if (!empty($_POST['correo'])) {?> <td align="center"><strong>CORREO</strong></td> 
    <?php }?>
    <?php if (!empty($_POST['sexo'])) {?> <td align="center"><strong>SEXO</strong></td> 
    <?php }?>
    <?php if (!empty($_POST['profesion'])) {?> <td align="center"><strong>PROFESION</strong></td> 
    <?php }?>
  </tr>
  <?php do {?>
  <tr>
   <?php if (!empty($_POST['nombre'])) { ?>   <td><?php echo $row_Recordset1['nombre'];?></td><?php }?>
   <?php if (!empty($_POST['celular'])) {?>   <td><?php print($row_Recordset1['celular']);?></td><?php }?>
   <?php if (!empty($_POST['PIN'])) {?>  <td><?php echo $row_Recordset1['PIN']; ?></td><?php }?>
   <?php if (!empty($_POST['telefono'])) {?>  <td><?php echo $row_Recordset1['telefono'];?></td><?php }?>
   <?php if (!empty($_POST['direccion'])) {?>  <td><?php echo $row_Recordset1['direccion'];?></td><?php }?>
   <?php if (!empty($_POST['correo'])) {?>   <td><?php echo $row_Recordset1['correo'];?></td><?php }?>
    <?php if (!empty($_POST['sexo'])) {?>   <td><?php echo $row_Recordset1['sexo'];?></td><?php }?>
    <?php if (!empty($_POST['profesion'])) {?> <td><?php echo $row_Recordset1['profesion'];?></td><?php }?>    
  </tr>
  <?php } while ($row_Recordset1 mysql_fetch_assoc($Recordset1));?>
</table>
<?php mysql_free_result($Recordset1);?>
__________________
http://www.solucionesrios.tk/

Visita mi Web!