Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/11/2010, 02:55
Avatar de mercabusca10
mercabusca10
 
Fecha de Ingreso: octubre-2010
Ubicación: Cordoba
Mensajes: 8
Antigüedad: 14 años, 3 meses
Puntos: 0
Relacionar Tablas

Hola. Mi consulta es la siguiente:

Tengo dos tablas y quisiera relacionarlas de forma que cuando me encuentre en la página del artículo me salga a que nombre de categoría pertenece dicho artículo, asi como su ID.

Las tablas son las siguientes:


INSERT INTO `pfs_article_us` (`id`, `tid`, `sord`, `title`, `content`, `keyword`, `display`, `sub_views`, `views`, `d_submit`, `d_update`, `active`) (EN ESTA TABLA SE ENCUENTRAN LOS ARTICULOS)

INSERT INTO `pfs_topic_us` (`id`, `title`, `p`, `sord`, `f_idx`) (ESTA TABLA ES LA DE LAS CATEGORIAS)


Yo estoy tratando de hacer algo así pero no lo consigo:


<?php
$re=mysql_query('select * from pfs_topic_us, pfs_article where pfs_topic_us.title=pfs_article_us.id ="'.$_GET['id'].'" ');
while($f=mysql_fetch_array($re)){
echo '<b><font face="Tahoma" size="2">'.$f['title'].'</font></b><br>';
}

?>




Muchas gracias a todos de antemano.


PD por si sirve las tablas tienen la siguiente estructura

CREATE TABLE `pfs_article_us` (
`id` int(8) NOT NULL auto_increment,
`tid` int(8) NOT NULL default '0',
`sord` int(8) NOT NULL default '0',
`title` varchar(120) NOT NULL default '',
`content` text NOT NULL,
`keyword` text NOT NULL,
`display` int(8) NOT NULL default '0',
`sub_views` bigint(11) NOT NULL default '0',
`views` bigint(11) NOT NULL default '0',
`d_submit` date NOT NULL default '0000-00-00',
`d_update` date NOT NULL default '0000-00-00',
`active` int(1) NOT NULL default '0',
PRIMARY KEY (`id`),
FULLTEXT KEY `content` (`content`,`keyword`,`title`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;



CREATE TABLE `pfs_topic_us` (
`id` int(8) NOT NULL auto_increment,
`title` varchar(120) NOT NULL default '',
`p` int(8) NOT NULL default '0',
`sord` int(8) NOT NULL default '0',
`f_idx` int(1) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `sord` (`p`,`sord`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;