I have a 2 table set up to handle authors for citations...
Author:
author_id
first_name
middle_name
last_name
Author_link:
link_id
citation_id
author_id
What needs to happen is, using a citation ID, i need to return the names of the authors in a specific format depending on how many authors are present for that particular citation.
for 1 author: last_name, first name middle_name
for 2 authors: last_name, first_name middle_name 'and' first_name(2) middle_name(2) last_name(2)
for 3 or more: last_name, first_name middle_name, first middle last ... 'and' first(n) middle(n) last(n)
my code is:
Code: Select all
$result_author=@mysql_query("SELECT al.id_author_, a.first_name, a.middle_name, a.last_name
FROM wfbiblio.author_link al
LEFT JOIN wfbiblio.author a on al.id_author_= a.id_author
WHERE id_citation_='$id_citation_'");
while ($row = mysql_fetch_assoc($result_author)){
$first_name=$row['first_name'];
$middle_name=$row['middle_name'];
$last_name=$row['last_name'];
$authors = $last_name . ", " . $first_name . " " . $middle_name . "/" . $authors;
}if you could help, i'll give you three virtual high fives and my sincerest gratitude.
thanks,
Wes