<?php session_name('scdc');
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// select the type from the database
// database connection details (change to whatever you need)
$HOST = 'localhost';
$DATABASE = 'k26bruc_cambsdata';
$USER = ';
$PASSWORD = ';
// connect to database
if(!$conn=mysql_connect('localhost','','')) {
echo("<li>Can't connect to $HOST as $USER");
echo("<li>mysql Error: ".mysql_error());
die;
}
// select database
if (!mysql_select_db($DATABASE,$conn)) {
echo("<li>We were unable to select database $DATABASE");
die;
}
?>
<p>Self Completion For : <?php echo(''.$_SESSION['ParishName'].''); ?>
<form action="scdc_selfcompletion.php" method="post">
<table width="800" border="1" cellspacing="2" cellpadding="3">
<tr>
<td colspan = '5'>Behaviour Alteration</td>
</tr>
<tr>
<td> </td>
<td>Product Type</td>
<td>Number Pledging</td>
<td>Energy Saved</td>
<td>Investment By The Community</td>
</tr>
<tr>
<td width="15%">Product 1</td>
<td width="27%">
<select name="bap1">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging1" type="text" id="pledging" maxlength="5" />
</td>
<td width="20%"><?php echo(''.$details['mesurements'].'')?></td>
<td width="19%"> </td>
</tr>
<tr>
<td>Product 2</td>
<td width="27%">
<select name="bap2">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging2" type="text" id="pledging" maxlength="5" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Product 3</td>
<td width="27%">
<select name="bap3">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging3" type="text" id="pledging" maxlength="10" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Product 4</td>
<td width="27%">
<select name="bap4">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging4" type="text" id="pledging" maxlength="5" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Product 5</td>
<td width="27%">
<select name="bap5">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging5" type="text" id="pledging" maxlength="5" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Product 6</td>
<td width="27%">
<select name="bap6">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging6" type="text" id="pledging" maxlength="5" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Product 7</td>
<td width="27%">
<select name="bap7">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging7" type="text" id="pledging" maxlength="5" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Product 8</td>
<td width="27%">
<select name = "bap8">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging8" type="text" id="pledging" maxlength="5" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Product 9</td>
<td width="27%">
<select name="bap9">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging9" type="text" id="pledging" maxlength="5" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Product 10</td>
<td width="27%">
<select name="bap10">
<option selected="selected">Select One</option>
<option value="Energy Efficient Cooking">Energy Efficient Cooking</option>
<option value="Re-Usable Bags">Re-Usable Bags</option>
<option value="Keep Fridge/Freezer Ice Free">Keep Fridge/Freezer Ice Free</option>
<option value="No Stand By">No Stand By</option>
<option value="Use Energy Meter">Use Energy Meter</option>
<option value="Use Radio Other Than TV">Use Radio Other Than TV</option>
<option value="Recycling">Recycling</option>
<option value="Stop Junk Mail">Stop Junk Mail</option>
</select>
</td>
<td width="19%">
<input name="pledging" type="text" id="pledging" maxlength="5" />
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan = '3'>Total Savings and Expenditure</td>
<td> </td>
<td> </td>
</tr>
</table>
<input type="Submit" name="select" value="select">
</form>
<?php
// if something has been chosen
if (!empty($select)) {
// select the type from the database
// database connection details (change to whatever you need)
$HOST = 'localhost';
$DATABASE = '';
$USER = ';
$PASSWORD = '';
}
// connect to database
if(!$conn=mysql_connect('localhost','','')) {
echo("<li>Can't connect to $HOST as $USER");
echo("<li>mysql Error: ".mysql_error());
die;
}
// select database
if (!mysql_select_db($DATABASE,$conn)) {
echo("<li>We were unable to select database $DATABASE");
die;
}
// if everything successful create query
// this selects all rows where the type is the one you chose in the dropdown
// * means that it will select all columns, ie name and type as i said above
$_POST['bap1'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap1'";
$_POST['bap2'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap2'";
$_POST['bap3'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap3'";
$_POST['bap4'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap4'";
$_POST['bap5'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap5'";
$_POST['bap6'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap6'";
$_POST['bap7'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap7'";
$_POST['bap8'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap8'";
$_POST['bap9'] = "SELECT * FROM Behaviour WHERE Product LIKE '$bap9'";
$_POST['bap10']= "SELECT * FROM Behaviour WHERE Product LIKE '$bap10'";
//product 1 sum
$result = mysql_query($_POST['bap1'],$conn) or die('Invalid query: ' . mysql_error());
$details = mysql_fetch_array($result);
$bap1units = $bappledging1 = $_POST['pledging1'];
$bap1mes = $details['mesurements'];
$bapanswer1 = $bap1mes*$bap1units;
?>
</body>