<?php

	include "library.php";

	$cxn = start_code( true );

	
		/* get parameters */

	$conversation_id = val( $_GET, 'conversationid' );

	$member_id = val( $_GET, 'memberid' );


		/* check them */

	crash_if_missing( $conversation_id, "conversation_id missing in get_chat_text", $cxn );
	
	crash_if_missing( $member_id, "member_id missing in get_chat_text", $cxn );


		/* get line(s) of text typed */

	$query = "SELECT profile.handle, text FROM chat_text LEFT JOIN profile ON profile.id = chat_text.typed_by WHERE conversation_id = ".$conversation_id." AND typed_by = ".$member_id." ORDER BY chat_text.id";

	$result = run_query( $query, $cxn );

	$text = "";

	for ($i=0; $i < mysql_num_rows($result); $i++)
	{
		$data = get_row( $result );

		$text .= $data['handle'].": ".$data['text']."\n";
	}

		/* delete them from the database */

	$query = "DELETE FROM chat_text WHERE conversation_id = ".$conversation_id." AND typed_by = ".$member_id;

	$result = run_query( $query, $cxn );


		/* send of the new lines of text */
	echo $text;

?>
