troubleshooting Question

Need to fetch data from 2 tables, mysql

Avatar of peps03
peps03 asked on
DatabasesPHPMySQL Server
4 Comments1 Solution496 ViewsLast Modified:
Hi, i have 2 tables, pages and keywords.

pages has a unique primary key (id)
keywords does not have a primary unique key. it stores keywords based on the pages.id

so an id can occur multiple times with different keywords.

i would like to output the pages id and some other columns with the keywords and date corresponding to the ids from the keywords table and add the keywords and date.

<table width="100%" border="0" cellspacing="2" cellpadding="2">
<?php
include 'connect.php';

$query = 	"SELECT pages.id, pages.aname, pages.bname, pages.taganame, pages.tagbname, 
				keywords.id keywords.keywords, keywords.date 
			FROM pages, keywords 
			WHERE pages.id = keywords.id";

		$result = mysql_query($query);
		while($output = mysql_fetch_array($result)){
			
			$id = 	 $output['id'];;
			$aname = $output['aname'];
			$bname = $output['bname'];
			$taganame = $output['taganame'];
			$tagbname = $output['tagbname'];
			$keywords = $output['keywords'];
			$date = $output['date'];
			
			echo "	
				  <tr>
					<td>$id</td>
					<td>$aname/$bname</td>
					<td>$taganame/$tagbname</td>
					<td>$keywords</td>
					<td>$date</td>
				  </tr>
			";
		}
?>
</table>

It outputs nothing, but also no errors.
What am i doing wrong?
Thanks!
ASKER CERTIFIED SOLUTION
innovasoft

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros