I have been trying some more to get this thing to order properly and I can't manage it.
So I have made this simpler piece of code which shows the basic principle of what I want to order.
I made a simple array which contains the ids of two documents.
I then run a query for each of the arrays to retrieve data on that particular document. Although I know it has no real effect because it's only selecting for one document I added an ORDER by year at the end.
The result is then to output the year of that document.
What I want is for the documents to be ordered by year when their outputted but with the code in this form I don't know how.
So can anyone, looking at how the code is dealing with the data, suggest a way to order the document ids in the array by the year data stored in the database.
Thanks,
Matt
<?php
error_reporting(E_ALL);
include('db_connect.php');
$docid[] = "18";
$docid[] = "19";
foreach ($docid as $id) {
$query="SELECT * FROM authorship left join authors on authorship.authorid = authors.authorid left join docs on authorship.docid = docs.docid left join type on authorship.typeid = type.typeid where docs.docid='$id' ORDER BY year";
$result=mysql_query($query);
$data=mysql_fetch_array($result);
}
?>