Ver Mensaje Individual
  #7 (permalink)  
Antiguo 29/08/2008, 16:54
Avatar de masterojitos
masterojitos
 
Fecha de Ingreso: julio-2008
Ubicación: Lima Callao Chucuito
Mensajes: 1.931
Antigüedad: 15 años, 9 meses
Puntos: 105
Respuesta: parsear codigo html

Cita:
Iniciado por marcadcat Ver Mensaje
Tengo el siguiente problema y me gustaria que me dieran la solución:
Tengo la siguiente tabla:
Código HTML:
<table> 
<tr>
      <td><a href="http://www.fila1.com">Fila 1</a></td>
      <td>Fila 2 </td>
</tr>
</table> 
Me gustaria guardar en la base de datos y en filas distintas el contenido de los td manteniendo tambien los enlaces
¿Como lo puedo hacer?
Saludos

Tu tabla de bd debe ser algo asi:

Código PHP:
CREATE TABLE link(
  
id_link int(2NOT NULL auto_increment,
  
nombre varchar(255NOT NULL,
  
url text NOT NULL,
  
target int(1NOT NULL default '0',
  
PRIMARY KEY  (id_link)

donde:
id_link => codigo identidad para cada link
nombre => es el nombre del link
url => logico no
target => si es 0, es _self y si es 1 sera _blank


y un registro de ejemplo puede ser:
Código PHP:
INSERT INTO link VALUES (1'Link 1''http://www.forosdelweb.com/'1); 
y tu codigo en el php quedaria asi:
Código PHP:
<table> 
<tr>
<?php
$rs
=mysql_query("select * from link");
while(
$row=mysql_fetch_row($rs)){
  (
$row[3]==0)?$target="_self":$target="_blank";
  echo 
'<td><a href="'.$row[2].'" target="'.$target.'">'.$row[1].'</a></td>';
}
?>
</tr>
</table>
__________________
Atte. MasterOjitos :ojotes:
Todo sobre Programación Web
Las ultimas tendencias en Efectos y Recursos Web: MasterOjitos Blog