Cita:
Iniciado por marcadcat 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(2) NOT NULL auto_increment,
nombre varchar(255) NOT NULL,
url text NOT NULL,
target int(1) NOT 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>