Location: PHPKode > projects > phpautotest > index.php
<?php
session_start();

require 'includes/phpautotest_config.php';
require 'includes/phpautotest_functions.php';

require 'includes/header.php';
require 'includes/top_menu.php';

restrict_access();

echo
"
The following are previously recorded snapshots. Click <b>perform test</b> and phpautotest will take another snapshot and report any changes.
";

// Send two queries to delete relevant data from `cases` and `page` tables
if($_GET['case_id'])
{
	$QUERY = <<<END

	DELETE FROM
		`$phpautotest_table_cases`
	WHERE case_id = $_GET[case_id]
END;

	phpautotest_send_query($QUERY);

	$QUERY = <<<END

	DELETE FROM
		`$phpautotest_table_page`
	WHERE case_id = $_GET[case_id]
END;

	phpautotest_send_query($QUERY);
}

// Get information about the test cases
$QUERY = <<<END

	SELECT $phpautotest_table_cases.*, COUNT($phpautotest_table_page.case_id) AS no_pages FROM $phpautotest_table_cases
	LEFT JOIN $phpautotest_table_page ON $phpautotest_table_cases.case_id = $phpautotest_table_page.case_id 
	GROUP BY $phpautotest_table_cases.case_id 
	ORDER BY $phpautotest_table_cases.case_id DESC

END;

$result = phpautotest_send_query($QUERY);

// Loop through all the cases
$num_rows = mysql_num_rows($result);

if($num_rows > 0)
{
	echo
	"
	<br><br>
	<table cellspacing='1' cellpadding='3' bgcolor='white' class = 'box'> 
	<tr bgcolor='#005896'>
	<td><font color='#FFFFFF'><b>id</b></font></td>
	<td><font color='#FFFFFF'><b>Time</b></font></td>
	<td><font color='#FFFFFF'><b>Description</b></font></td>
	<td><font color='#FFFFFF'><b>No of pages</b></font></td>	
	<td><font color='#FFFFFF'><b>Options</b></font></td>
	</tr>
	";

	for($i = 0; $i < $num_rows; $i++)
	{
		$case = mysql_fetch_assoc($result);
		$start_timestamp = date('h:m A, d M', $case['start_timestamp']);
		
		echo
		"
		<tr bgcolor='#DDDDDD'>
		<td>$case[case_id]</td>
		<td>$start_timestamp</td>
		<td>$case[description]</td>
		<td>$case[no_pages]</td>
		<td><a href = 'perform_test.php?case_id=$case[case_id]'>perform test</a>&nbsp;&nbsp;<a href = '$PHP_SELF?case_id=$case[case_id]'>delete</a>&nbsp;&nbsp;<a href = 'edit_test.php?case_id=$case[case_id]'>edit test</a>&nbsp;&nbsp;</td>
		</tr>
		";
	}

	echo
	"
	</table>
	";
}
else
{
	phpautotest_show_message($phpautotest_message['no_test_cases']);
}
require 'includes/footer.php';
?>
Return current item: phpautotest