Thanks for your Reply Harmor ... i think we are on the right tracks,
I've been playing around with the concept you gave me with little joy, i thought i'd post you the code i currently have on this page and see whether you would be able to help me a little more. All the DB connection is done in a master PHP ... the code below is from one of the include files.
Applogies if its a little confusing, you will see that it generates a list of the clients printed as "surname,first name" .... just after the name of each candidate is where i want to place the flag.
The table which holds the determining filed is called "students" and the field is called "withdrawaldate" ...
Thanks so much for you help, this will call a nice conslusion to my project once its working.
If you need any more info then please let me know .. i appologise for asking such complicated questions but i am still new to the PHP world.
Rob
<H3>Welcome to the Odyssey Training Student Database</H3>
<?php
$result = mysql_query("SELECT * FROM students ORDER BY surname");
$counter = 0;
while ($student_result = mysql_fetch_array($result))
$counter++;
if ($counter == 0) print "<B>There are currently no students in the database";
else if ($counter == 1) print "<B>There is currently one student in the database";
else print "<B>There are currently $counter students in the database";
if ($cid != "")
{
$result = mysql_query("SELECT * FROM students WHERE cid=$cid ORDER BY surname");
$counter = 0;
while ($student_result = mysql_fetch_array($result))
$counter++;
if ($counter == 0) print " of which none are associated with this company</B><BR>";
else if ($counter == 1) print " of which one is associated with this company:</B><BR>";
else print " of which $counter are associated with this company</B><BR>";
print "<BR><B><A HREF=\"student.php\">View all companies</A></B><BR>\n";
$companyquery = mysql_query("SELECT id,company FROM companyinfo WHERE id=$cid ORDER BY company");
$companyresults = mysql_fetch_array($companyquery);
if ($companyresults[1] != "")
{
print "<BR><B>Company Name: <A class=\"company\" HREF=\"student.php?do=companyview&cid=$companyresults[0]\">$companyresults[1]</A></B><BR>\n";
$result = mysql_query("SELECT surname,givenname,id FROM students WHERE cid=$cid ORDER BY surname");
while($book_row = mysql_fetch_array($result))
{ $counter++;
print "<LI><A class=\"student\" HREF=\"student.php?do=view&sid=$book_row[2]&cid=$cid\">$book_row[0], $book_row[1]</A><BR>\n";
}
print "<LI><A class=\"student\" HREF=\"student.php?do=add_form&cid=$cid\"><I>Add Student</I></A><BR>\n";
}
else
{
print "<BR>Company not found<BR><BR>";
}
}
else
{
$companyquery = mysql_query("SELECT id,company FROM companyinfo ORDER BY company");
print "</B><BR>\n";
while($companyresults = mysql_fetch_array($companyquery))
{
print "<BR><B>Company Name: <A class=\"company\" HREF=\"student.php?do=companyview&cid=$companyresults[0]\">$companyresults[1]</A></B><BR>\n";
$result = mysql_query("SELECT surname,givenname,id FROM students WHERE cid=$companyresults[0] ORDER BY surname");
$studentcounter = 0;
while($book_row = mysql_fetch_array($result))
{
$studentcounter++;
print "<LI><A class=\"student\" HREF=\"student.php?do=view&sid=$book_row[2]&cid=$companyresults[0]\">$book_row[0], $book_row[1]</A><BR>\n";
}
if ($studentcounter == 0)
print "<LI>There are no students associated with this company <A HREF=\"student.php?do=add_form&cid=$companyresults[0]\"><I>Add one</I></A><BR>";
else
print "<LI><A class=\"student\" HREF=\"student.php?do=add_form&cid=$companyresults[0]\"><I>Add another</I></A><BR>";
}
}
?>