I am putting together an archive of articles from a magazine covering 8 years. However I am in need of some help to finish off a MySQL select and place it on the screen in a meaningful manner.
The screen shot attached (See Below) is the way that it looks now and if there is more than 1 author they all take up a row with the same title and overview of the article. so 1 author and 4 co authors takes up 5 almost duplicate rows which is not good.
My aim is to get the authors one underneath the other to the left column with one instance of the title and overview in the right.
$mycat is taken from the calling page and inserted into the select statement.
Any help very much appreciated.
<!--CONNECT TO DATABASE-->
<?php
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
?>
<!--MAKE THE SELECTION-->
<?PHP
$query = ("
SELECT author.title_id, author.prefix, author.first_name,author.last_name,articles.thetitle,articles.issue_no,articles.article_path,articles.overview
FROM author, articles
WHERE articles.category = \"".$mycat."\"
AND author.title_id = articles.id
GROUP BY articles.thetitle, author.last_name ASC
")or die(mysql_error());
$result = mysql_query($query);
?>
<!--CREATE THE TABLE-->
<table>
<tr><th>Author</th><th> </th><th>Title</th><th><Read Article</th></tr>
<!--POPULATE THE TABLE-->
<?php
// Print out result
while($row = mysql_fetch_array($result)){
?>
<tr><td valign="top">
<?php echo $row['prefix'] ;?> <?php echo $row['first_name'] ;?> <?php echo $row['last_name'] ;?>
</td><td> </td><td>
<strong><?php echo $row['thetitle'] ;?></strong><br><?php echo $row['overview'] ;?></td><td valign="top">
<a href="http://path-to-files/issue<?php echo $row['issue_no'] ;?>/<?php echo $row['article_path'] ;?>"target="_blank"><img src="book-image.gif" alt="Follow link to read" /></a>
</td></tr>
<?php } ?>
<!--END THE TABLE-->
</table>
MySQL tables used
CREATE TABLE `articles` (
`id` int(5) NOT NULL AUTO_INCREMENT,
`thetitle` text NOT NULL,
`volume_no` text NOT NULL,
`issue_no` text NOT NULL,
`category` text NOT NULL,
`country` text NOT NULL,
`article_path` text NOT NULL,
`overview` text NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `author` (
`author_id` tinyint(11) NOT NULL AUTO_INCREMENT,
`title_id` tinyint(11) NOT NULL,
`prefix` text NOT NULL,
`first_name` text NOT NULL,
`last_name` text NOT NULL,
`info` text NOT NULL,
PRIMARY KEY (`author_id`)
)