Foros del Web » Programando para Internet » PHP »

Texto en php

Estas en el tema de Texto en php en el foro de PHP en Foros del Web. Hola¡ estoy haciendo un blog para apuntes de univercidad la tabla de la base de datos tengo: id (int) asignatura (text) tema (text) apunteuni (longtext) ...
  #1 (permalink)  
Antiguo 01/06/2011, 21:49
Avatar de figardi  
Fecha de Ingreso: mayo-2011
Mensajes: 18
Antigüedad: 12 años, 11 meses
Puntos: 0
Información Texto en php

Hola¡ estoy haciendo un blog para apuntes de univercidad la tabla de la base de
datos tengo:

id (int)
asignatura (text)
tema (text)
apunteuni (longtext)

El problema es que cuando hago un listado de los apuntes, lo que pongo en el formulario lo hago con salto de linea pero cuando hago el listado esta todo junto
no hay salto de linea, solo en apunteuni.
Lo he intentado con NL2BR pero soy novato en esto.
Por fabor si alguien puede ayudarme.
  #2 (permalink)  
Antiguo 02/06/2011, 00:07
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Texto en php

Seguro que es para la universidad?, por favor muestra el codigo con el que has intentado y no funciona, porque con nl2br($texto); deberia ser suficiente.
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 05/06/2011, 22:01
Avatar de figardi  
Fecha de Ingreso: mayo-2011
Mensajes: 18
Antigüedad: 12 años, 11 meses
Puntos: 0
Respuesta: Texto en php

<?php require_once('Connections/apuntes2.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"];

$maxRows_Recordset1 = 3;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_apuntes2, $apuntes2);
$query_Recordset1 = "SELECT * FROM resgistros";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $apuntes2) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?>
<!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=iso-8859-1' />
<title>Documento sin t&iacute;tulo</title>
<?php
$mes[0]="-";
$mes[1]="Enero";
$mes[2]="Febrero";
$mes[3]="Marzo";
$mes[4]="Abril";
$mes[5]="Mayo";
$mes[6]="Junio";
$mes[7]="Julio";
$mes[8]="Agosto";
$mes[9]="Septiembre";
$mes[10]="Octubre";
$mes[11]="Noviembre";
$mes[12]="Diciembre";
$dia[0]="Domingo";
$dia[1]="Lunes";
$dia[2]="Martes";
$dia[3]="Miércoles";
$dia[4]="Jueves";
$dia[5]="Viernes";
$dia[6]="Sábado";
$gisett=(int)date("w");
$mesnum=(int)date("m");
$hora = date(" H:i",time());
echo $dia[$gisett].", ".date("d")." de ".$mes[$mesnum]." de ".date("Y");
?>
</td>
</tr>
</table>
<style type="text/css">
body,td,th {
color: #FFF;
}
body {
background-color: #0F0F0F;
}
</style>
<div class="sidebar1">
<ul class="nav">
<li><a href="index.php">Home</a></li>
<li><a href="listado.php">Listado de Apuntes</a></li>
<li><a href="admin.php">Poner Apuntes</a></li>
<li><a href="contactar.php">Contactar</a></li>
</ul>
<p>&nbsp;</p>

<table border="0" align="center">
<tr>
<td><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>"><img src="images/Backward.png" alt="" height="36" /></a>
<?php } // Show if not first page ?></td>
<td><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>"><img src="images/Arrow Left.png" alt="" height="36" /></a>
<?php } // Show if not first page ?></td>
<td><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>"><img src="images/Arrow Right.png" alt="" height="36" /></a>
<?php } // Show if not last page ?></td>
<td><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>"><img src="images/Forward.png" alt="" height="36" /></a>


<?php } // Show if not last page ?></td>
</tr>
</table>
<p>&nbsp;</p>

</div>
<div>
<?php do { ?>


<br />
<br />
<br />
<table width="80%" align="left">
<tr>
<td><img src="images/linea.png" width="750" height="2" /></td>
</tr>
<tr>
<td><span class="aa">Asignatura:</span> <?php echo $row_Recordset1['asignatura']; ?> <span class="aa">Tema:</span> <?php echo $row_Recordset1['tema']; ?></td>
</tr>
<tr>
<td class="aa">Apunte: </td>
</tr>
<tr>
<td><?php echo $row_Recordset1['apuntesuni']; ?></td>
</tr>
<tr>
<td><img src="images/linea.png" alt="" width="750" height="2" /></td>
</tr>
</table>
<br />
<br />
<br />
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</div>

<div class="footer"><img src="images/bajo.jpg" width="960" height="57" /></a>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
  #4 (permalink)  
Antiguo 05/06/2011, 23:18
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: Texto en php

Código PHP:
Ver original
  1. <td><?php echo nl2br($row_Recordset1['apuntesuni']); ?></td>

Has probado asi y no funciona?
__________________
- León, Guanajuato
- GV-Foto
  #5 (permalink)  
Antiguo 06/06/2011, 06:30
Avatar de figardi  
Fecha de Ingreso: mayo-2011
Mensajes: 18
Antigüedad: 12 años, 11 meses
Puntos: 0
Respuesta: Texto en php

Hola¡ ahora lo formatea pero no donde yo quiero, si me mandas un privado con tu direccion
de correo te mando el codigo.
Muchas Gracias
Fidel
  #6 (permalink)  
Antiguo 06/06/2011, 06:52
Avatar de figardi  
Fecha de Ingreso: mayo-2011
Mensajes: 18
Antigüedad: 12 años, 11 meses
Puntos: 0
Respuesta: Texto en php

Muchas Gracias de corazon ya funciona muy bien, si quieres el codigo te lo paso.
Gracias de nuevo.

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:14.