| 
| Um eine Publikation einer DNA-Probe zuzuordnen, geben Sie bitte einen Teil des Paper-Titels ein sowie die gewünschten DNA-Nummern oder Gen Bank Accession Numbers. Sie können in einem ersten Schritt auch nur prüfen lassen, ob die Publikation schon in der Datenbank ist. |  
			        | Search for Title: |  | or show all Papers: >     add new publication |  
    | and Gen Bank Numbers: |  | Please separate numbers with semicolon (e.g. AJ746400;AJ746394) |  
    | or DNA Extraction Numbers: |  | Please separate numbers with semicolon (e.g. 236;289;324) |  | Please select a publication!"; }
       
    if($_POST['y']=="")
    { unset($y); 
    echo "Please select a gentic locus!"; }
    
    else {    
    if(isset($_POST['x']))
    {$mykey = key($_POST['formPublications']);
     if($mykey = $_POST['x'])
        { 
        $IDPublication = $_POST['formPublications'][$mykey];
     } }  //if($_POST['x']!="")
    
    foreach($_POST['y'] as $index2 => $check)
    {
      if(isset($check))
      {
        $IDAmplification = $_POST['IDAmplification'][$check];
        $IDDNA = $_POST['IDDNA'][$check];
        $GeneticLocusTest = $_POST['formGeneticLocus'][$check];
        
        $resultPub= "SELECT publications.ID_Publications, " .
              "publications.Editors, " .
              "publications.Year, " .
              "publications.Title, " .
              "journals.Journal_Display, " .
              "publications.Volume, " .
              "publications.Pages, " .
              "publications.Book, " .
              "publications.Publisher, " .
              "publications.Link " .
              "FROM publications " .
              "LEFT JOIN journals ON publications.FK_Journal = journals.ID_Journal " .
              "WHERE publications.ID_Publications = '$IDPublication'";
    $sqlPub = mysql_query($resultPub);
    
    
    
    if(mysql_num_rows($sqlPub))
    {
    $gesamt = mysql_num_rows($sqlPub); 
    for ($i=1; $i<=$gesamt; $i++) {
    $row=mysql_fetch_array($sqlPub);
    $publications[] = $row['ID_Publications'];
    foreach ($publications as $Test)
    {
$resultaut = "SELECT publications_authors.FK_Publications, " .
           "authors.Author, " .
           "publications_authors.Order " .
           "FROM  publications_authors, authors " .
           "WHERE publications_authors.FK_Author = authors.ID_Author " .
           "  AND publications_authors.FK_Publications = '$Test' " .
           "ORDER BY publications_authors.Order";
        
    $sqlaut = mysql_query($resultaut);           
while ($roww = mysql_fetch_object($sqlaut))
    {
    
      if(isset($Author[$roww->ID_Publications]))
      {$Author[$roww->ID_Publications] .= ", ";}
      else
      {$Author[$roww->ID_Publications] .= ""; }
      $tmp = $roww->Author;
      $Author[$roww->ID_Publications] .= $tmp; 
      $View = $Author[$roww->ID_Publications]; 
      }}    
    
    
$Paper = $View;
if($row['Editors']) { $Paper .= " ".$row['Editors']; }
$Paper .= " (".$row['Year']."): ".$row['Title'];
if($row['Journal_Display']) { $Paper .= " ".$row['Journal_Display']; }
if(!$row['Journal_Display']) { $Paper .= " IN: ".$row['Book']." ".$row['Publisher']; }
if($row['Volume']) { $Paper .= " ".$row['Volume'].": "; }
if($row['Pages']) { $Paper .= " ".$row['Pages']."."; }
//if($row['Link']) { $Paper .= " ".build_href1($row['Link'],$row['Link']); }
    
     }  }  
    $resultTest = "SELECT ID_Pub_Amp, FK_Publications, FK_Amplification FROM publications_amplifications " .
                  "WHERE FK_Publications = '$IDPublication' " .
                  "AND FK_Amplification = '$IDAmplification'";
           
    $sqlTest = mysql_query($resultTest);
    if(mysql_num_rows($sqlTest))
    { echo "Die Verbindung zwischen dieser Publikation und dieser Amplifikation wurde bereits gespeichert!";}
    else {
            
        $result1 = "INSERT INTO publications_amplifications (FK_Publications, FK_Amplification, FK_DNA, Paper_Cache, GeneticLocus, Created_Who) VALUES ('$IDPublication','$IDAmplification','$IDDNA','$Paper','$GeneticLocusTest','$log')";
        $sql1 = mysql_query($result1);
        
#######################################Error 1###############################################################
if(!$sql1)
{ $msg = $result1."\n";
  $msg .= "####Error 1####";
  if($debug == '1') echo $msg;
  trigger_error($msg, E_USER_ERROR);
  include ("../config/Errorreport.php");   }
  
#############################################################################################################          
        
       } 
      }
   
    }
    
    
    if($sql1)
    { echo "Data have been saved!"; }
    
    }
    
    
    
    }
    
    
    
    
    
    
    
    
    
    if($formSubmitCheck)
    {
    if(empty($formSearchTitle) and !isset($formShowAll))
    { echo "Please enter a Title! ";}
    if(!empty($formSearchTitle) and isset($formShowAll))
    { echo "Please neither enter a Title or select the checkbox!
 ";}
    
    else {
    $result1= "SELECT publications.ID_Publications, " .
              "publications.Editors, " .
              "publications.Year, " .
              "publications.Title, " .
              "journals.Journal_Display, " .
              "publications.Volume, " .
              "publications.Pages, " .
              "publications.Book, " .
              "publications.Publisher, " .
              "publications.Link " .
              "FROM publications " .
              "LEFT JOIN journals ON publications.FK_Journal = journals.ID_Journal " .
              "WHERE publications.Title LIKE '%$formSearchTitle%'";
    $sql1 = mysql_query($result1);
if(!mysql_num_rows($sql1))
    {echo "No hits found for: ".$_POST['formSearchTitle']."
 ";}
    else
    {
    echo "
 ";
    echo "";
    }}
    
    if(empty($formDnaBankNumber) and empty($formGenBankNumber))
    { echo "Please enter a Gen Bank Number or DNA Extraction Number!";}
    
    else {
    
            $DnaArray = explode(";", $formDnaBankNumber);
            while($i = each($DnaArray))
            {
            $Dna = trim($i[1]);
            $string .= 'dnabanknumbers.Dna_Bank_Number = "'.$Dna.'" OR '; }
            
            $l=strlen ($string);
            $max = $l-4;
            $str = "(".substr($string, 0, $max).")";
            
            $GenBankArray = explode(";", $formGenBankNumber);
            while($i = each($GenBankArray))
            {
            $Gen = trim($i[1]);
            $stringGen .= 'amplifications.GenBankNumber = "'.$Gen.'" OR '; }
            
            $l=strlen ($stringGen);
            $maxGen = $l-4;
            $str1 = "(".substr($stringGen, 0, $maxGen).")";
            
                
$result3 = "SELECT amplifications.ID_Amplification, dnabanknumbers.Dna_Bank_Number, " .
           "amplifications.GenBankNumber, " .
           "amplifications.Amplification_Success, " .
           "amplifications.Amplification_Date, " .
           "amplifications.Link, " .
           "amplifications.FK_DNA, " .
           "geneticlocus.GeneticLocus " .
           "FROM amplifications
            LEFT JOIN dnabanknumbers ON amplifications.FK_DNA = dnabanknumbers.ID_DNA
            LEFT JOIN geneticlocus ON amplifications.FK_GeneticLocus = geneticlocus.ID_GeneticLocus
            WHERE ";
           if($formDnaBankNumber != "") {$result3 .= $str; }
           if($formDnaBankNumber != "" and $formGenBankNumber != "")
           {$result3 .= " OR "; } 
           if($formGenBankNumber != "") {$result3 .= $str1; }
           $result3 .= " ORDER BY dnabanknumbers.Dna_Bank_Number";
$sql3 = mysql_query($result3);    
if(!mysql_num_rows($sql3))
{echo "No Amplifications found";}
else { 
echo "";
}
    
    
    }
    
    
    
    }
    
    
    ?>";
    echo "| 
 |  ";
    $gesamt = mysql_num_rows($sql1); 
    for ($i=1; $i<=$gesamt; $i++) {
    $row=mysql_fetch_array($sql1);
    $publications[] = $row['ID_Publications'];
    foreach ($publications as $Test)
    {
$result2 = "SELECT publications_authors.FK_Publications, " .
           "authors.Author, " .
           "publications_authors.Order " .
           "FROM  publications_authors, authors " .
           "WHERE publications_authors.FK_Author = authors.ID_Author " .
           "  AND publications_authors.FK_Publications = '$Test' " .
           "ORDER BY publications_authors.Order";
$sql2 = mysql_query($result2);           
while ($roww = mysql_fetch_object($sql2))
    {
    
      if(isset($Author[$roww->ID_Publications]))
      {$Author[$roww->ID_Publications] .= ", ";}
      else
      {$Author[$roww->ID_Publications] .= ""; }
      $tmp = $roww->Author;
      $Author[$roww->ID_Publications] .= $tmp; 
      $View = $Author[$roww->ID_Publications]; 
      }}    
    
    
echo "| Please select a publication |  ";
echo "|  | ".$View,
$row['Editors'] ? " ".$row['Editors'] : "",
" (".$row['Year']."): ".$row['Title'],
$row['Journal_Display'] ? " ".$row['Journal_Display'] : " IN: ".$row['Book']." ".$row['Publisher'],
$row['Volume'] ? " ".$row['Volume'].": " : "",
$row['Pages'] ? " ".$row['Pages']."." : "",
$row['Link'] ? " ".build_href1($row['Link'],$row['Link']) : "";
echo " |  ";
    
     }
     echo "| 
 |  |  | 
 |  |  |  |