este es my codigo de consulta ..
Código PHP:
<?php
$conexion = mssql_connect("localhost", "sa", "123");
mssql_select_db("veracruz", $conexion);
$queEmp = "SELECT ID, nombre_via, shape_leng FROM ferrocarril";
$resEmp = mssql_query($queEmp, $conexion);
$totEmp = mssql_num_rows($resEmp);
?>
<table width="58%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td bgcolor="#CCCCCC"><div align="center">ID</div></td>
<td bgcolor="#CCCCCC"><div align="center">Nombre de via </div></td>
<td bgcolor="#CCCCCC"><div align="center">Shape_Leng</div></td>
<td bgcolor="#CCCCCC"><div align="center">KM</div></td>
</tr>
<?php
if( $totEmp > 0 ) {
while( $row_sel2 = mssql_fetch_array($resEmp) ) {
?>
<tr>
<td bgcolor="#FFFFF0"><div align="left"> <a href="individual.php?variable1=<?php echo $row_sel2['CVE_ELECT']?>&variable2=<?php echo $row_sel2['NOMBRE'] ?>&variable3=<?php echo "ver" ?> "target="_blank"><?php echo $row_sel2['ID'] ?> </a></div></td>
<td bgcolor="#FFFFF0"><div align="left"><?php echo $row_sel2['nombre_via'] ?></div></td>
<td bgcolor="#FFFFF0"><div align="left"><?php echo $row_sel2['shape_leng'] ?></div></td>
<td bgcolor="#FFFFF0"><div align="left">
<?php
$hola = $row_sel2['shape_leng'];
$hola1 = $hola;
settype($hola1, 'string');
if ($hola1[2]!=0){
$var1=$hola;
$a=($var1*111);
$x=$a*.175;
$y=$x/100;
$z=$a+$y;
echo $z."KM";
}
if ( $hola1[2]==0 && $hola1[3]!=0){
$var1=$hola;
$a=($var1*111);
$x=$a*.175;
$y=$x/100;
$z=$a+$y;
echo $z."KM";
}
if ( $hola1[2]==0 && $hola1[3]==0 && $hola1[4]!=0){
$var1=$hola;
$a=($var1*111);
$x=$a*.175;
$y=$x/100;
$z=$a+$y;
echo $z."KM";
}
if ( $hola1[2]==0 && $hola1[3]==0 && $hola1[4]==0 && $hola1[5]!=0){
$var1=$hola;
$a=($var1*111);
$x=$a*.175;
$y=$x/100;
$z=$a+$y;
echo $z."KM";
}
if ( $hola1[2]==0 && $hola1[3]==0 && $hola1[4]==0 && $hola1[5]==0 && $hola1[6]!=0){
$var1=$hola;
$a=($var1*111);
$x=$a*.175;
$y=$x/100;
$z=$a+$y;
echo $z."KM";
}
?></div></td>
</tr>
<?php
}
}
?>
</table>
gracias