", $foo); $foobar2 = eregi_replace("%%ITALIC", "", $foobar); $barfoo = eregi_replace("%ITALIC;", "", $foobar2); $barfoo2 = eregi_replace("%ITALIC", "", $barfoo); $blortfoo = eregi_replace("%eacute;", "é", $barfoo2); $blortfoo2 = eregi_replace("%lt;", "<", $blortfoo); $blortfoo3 = eregi_replace("%gt;", ">", $blortfoo2); $blortfoo4 = eregi_replace("%amp;", "&", $blortfoo3); $farble = eregi_replace("%plus;", "+", $blortfoo4); $finalCellContents = stripslashes($farble); $colname = mysql_field_name ($result, $i); switch ($colname) { case from_id: $from_id[$j] = "$finalCellContents "; if ($ref != "addressee") $people_id = substr($from_id[$j],1); break; case to_id: $to_id[$j] = "$finalCellContents "; if ($ref == "addressee") { if ( preg_match("/P.*$/",$to_id[$j]) ) { $people_id = $to_id[$j]; } else { $people_id = substr($to_id[$j],1); } } break; case letter_id: $letter_id[$j] = "$finalCellContents "; break; case letter_to: if ($ref == "addressee") $full_name_to = $finalCellContents; $letter_to[$j] = " $finalCellContents "; break; case letter_from: $letter_from[$j] = " $finalCellContents "; break; case date: $date[$j] = $finalCellContents; break; case from_address: $from_address[$j] = $finalCellContents; break; case text: $txt = $finalCellContents; $text = ereg_replace("\*\*\*","

",$txt); break; case prefix: if ($j == 0) { $full_name = "$row[$i] "; } break; case first_name: if ($j == 0) { $first_name = $row[$i]; $full_name .= " $row[$i] "; } break; case last_name: if ($j == 0) { $full_name .= " $row[$i]"; } break; case new_name_variants: if ($j == 0) { if ($full_name == " ") { $full_name = " $row[$i]"; } elseif ($row[$i] != "" && $first_name == "") { $allNameVariants = $row[$i]; $positionOfFirstSemiColon = strpos($allNameVariants,';'); if (! $positionOfFirstSemiColon) { $positionOfFirstSemiColon = strlen($allNameVariants); } $firstNameVariant = substr($allNameVariants,0,$positionOfFirstSemiColon); $full_name .= " ($firstNameVariant)"; } } break; } } $j++; } $cnt = 0; // echo "
debug, $myCntr, $j"; echo "

"; $whichSpecialList = "correspSpecialSenders_db.php3"; if ($full_name_to != "") { $whichSpecialList = "correspSpecialAddressees_db.php3"; } $full_name = getFullName($from_id[$cnt]); echo "

DATE: $date[$cnt]

LETTER #: $letter_id[$cnt]

To:

$letter_to[$cnt]

From:

$letter_from[$cnt]

Address of Sender:

$from_address[$cnt]


Text:

$text

List of all letters by $ref:

"; if ($ref == "addressee") { echo " $full_name >> "; } else { echo " $full_name >> "; } echo "

General information about $ref:

$full_name

"; $transactionCheckQuery = "SELECT ledger.ledger_id, client, name_id, year, month, day, cost FROM ledger, transz WHERE name_id = '$from_id[$cnt]' and ledger.ledger_id = transz.ledger_id ORDER BY year, month, day"; if ($ref == "addressee") { $transactionCheckQuery = "SELECT ledger.ledger_id, client, name_id, year, month, day, cost FROM ledger, transz WHERE name_id = '$to_id[$cnt]' and ledger.ledger_id = transz.ledger_id ORDER BY year, month, day"; } // ************* // // Check to see if there are any transactions for this person, // since no point showing a link if there are none: $resultTmp = runSQLQuery($transactionCheckQuery); if ($resultTmp) { $rowsTmp = mysql_num_rows ($resultTmp); if ($rowsTmp > 0) { $transactionFlag = 1; } } if ($transactionFlag) { if ($ref == "addressee") { echo "

Reference to transactions by $ref:

"; } else { echo "

Reference to transactions by $ref:

"; } echo "

$full_name

"; } } } #### end of function display_sql_results #### ## End of all functions ## ########################################################################################### ## Begin body of script ## getSQL(); ## $record is passed on the URL by the user, on an HREF, or through ## another script, e.g.: ## Oh, and here there might also be one non-SQL-related param, to ## pick which of the client letters to display, $myCnt. ## http://mama.stg.brown.edu/projects/tirocchi/database/corresp_db.php3?record=L003&footest=0 $field = "from_id"; if ( preg_match("/L.*$/", $record) ) $field = "letter_id"; $who = "from_id"; if ($referer == "addressee") $who = "to_id"; $query = "SELECT letter_id, to_id, from_id, ref_id, ledger_id, date, year, letter_to, letter_from, from_address, text, date_for_sorting, prefix, first_name, last_name, new_name_variants FROM corresp, people WHERE people.name_id = corresp.$who AND $field='$record' ORDER BY date_for_sorting, date, letter_id"; // ======================================================= // // Because the records need to be sorted by date_for_sorting, globally, this has to be done. // N.B. that date_for_sorting with 0000-00-00 sort first, and within that, dates with "n.d." // sort before dates like "Sunday morning" because I added a space: " n.d. " to ensure it. // $myLetterID = $record; if ( ! preg_match("/L.*$/", $record) ) { $queryTmp = "SELECT letter_id, date FROM corresp WHERE from_id = '$record' ORDER BY date"; $tmpResult = runSQLQuery($queryTmp); $row = mysql_fetch_array($tmpResult); $myLetterID = $row[0]; } $query2 = "SELECT * FROM corresp ORDER BY date_for_sorting, date, letter_id"; $resultForBrowsing = runSQLQuery($query2); $numrows = mysql_num_rows ($resultForBrowsing); for ($counter=0; $counter<$numrows; $counter++) { $row = mysql_fetch_array ($resultForBrowsing); if ($counter == $numrows-1) { $next_id = $row[0]; } else { $prev_id = $curr_id; $curr_id = $row[0]; if ($curr_id == $myLetterID) { $numrows = $counter+2; } } } if ($record == $next_id) { $next_id = ""; $prev_id = $curr_id; } // ======================================================= // if ($query) { // Execute the SQL query here and display the results $result = runSQLQuery($query); if ($result) { display_sql_results ($result, $query, $card); } else { err_msg ("MySQL Error", "MySQL Error"); echo "\t

Query = ", $query, "

\n"; $query = ""; } } // echo "\t
\n"; #################################################################################### ?>
"; if ($prev_id != '') { echo " <<"; } echo " Browse All Letters"; if ($next_id != '') { echo " >>"; } echo "

"; ?>

List of Senders   |   List of Addressees