I want to produce a pdf document using mysql and TCPDF.
I can do this OK in some circumstances but I now have a problem. I have two tables - documents and parties - they are linked by a common field docid.
I have for table documents, the fields:
docid, doctitle, idcode
and for the parties table:
partyid, docid, party (the field party is the name of the party)
For any document there could be any number of parties and for a single idcode there could be any number of documents.
For example, for idcode = 12345 there might be 2 documents called doctitle 1 and doctitle 2. For doctitle 1 there are 3 parties to it party1, party 2 and party 3. For doctitle 2 there are two parties - party4 and party 5.
For any idcode (which is passed through by the url) I want the pdf to give a list such as:
Doctitle 1:
party name 1
party name 2
party name 3
Doctitle 2:
party name 4
party name 5
Part of my code is:
mysql_select_db($database_process, $process);
$result2 = mysql_query("SELECT parties.docid, GROUP_CONCAT(party SEPARATOR ‘<br>’) AS partylist, documents.doctitle
FROM parties INNER JOIN documents ON parties.docid=documents.docid
WHERE parties.idcode = ‘$appidpassed’
GROUP BY parties.docid
LIMIT 1
") or die(mysql_error());
while($row = mysql_fetch_array($result2))
{
$doctitle = $row[‘doctitle’];
$parties = $row[‘partylist’];
}
and then further down the page:
$doctitle<br>
$parties
This only gives one document and the parties associated with it. I know the solution is probably easy but I can’t see it.
Does anyone have any ideas?