<?php

	include "library.php";

	$cxn = start_code();
	

			/* get variables */

	$id = val( $_SESSION, "id" );


			/* start page */

	page_header( "", $cxn );


		/* check parameters */

	crash_if_missing( $id, "id missing in remove_from_inbox", $cxn );


		/* search each message */

	$query = "SELECT id as message_id FROM message WHERE receiver_id = ".$id." AND show_in_inbox = 'yes'";

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

	$count = 0;

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

		if (val( $_POST, "id".$data['message_id'] ) == "on")
		{
			run_query( "UPDATE message SET show_in_inbox = 'no' WHERE id = ".$data['message_id'], $cxn );
			$count++;
		}
	}

	if ($count == 0)
		echo black( "No messages were selected<br><br>" );
	else
	if ($count == 1)
		echo black( "Message removed<br><br>" );
	else
		echo black( "Messages removed<br><br>" );

	echo show_link( "Return", "mailboxes.php", "box", "inbox" );

?>

