Code: Select all
<html>
<head>
<title>Solvent Calculations</title>
</head>
<body>
<form name="myform" action="process1.php" method="POST">
<input type="hidden" name="check_submit" value="1" />
<br />
Choose the solvents:
<input type="checkbox" name="Solvents[]" value="1,1-dimethylhydrazine" checked="checked" /> 1,1-dimethylhydrazine
<input type="checkbox" name="Solvents[]" value="isobutene" /> isobutene
<input type="checkbox" name="Solvents[]" value="2-ethoxyethyl acetate" /> 2-ethoxyethyl acetate
<input type="checkbox" name="Solvents[]" value="methyl tert-butyl ether" /> methyl tert-butyl ether
<br /><br />
<input type="submit" />
</form>
</body>
</head>
</html>Code: Select all
<?php
if (array_key_exists('check_submit', $_POST)) {
if ( isset($_POST['Solvents']) ) {
$_POST['Solvents'] = implode(', ', $_POST['Solvents']); //Converts an
array into a single string
}
echo "Solvents you chose: {$_POST['Solvents']}<br />";
} else {
echo "You can't see this page without submitting the form.";
}
$con = mysql_connect("localhost","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("solvents", $con);
$result = mysql_query("SELECT * FROM solvents
WHERE Name='{$_POST['Solvents']}'");
while($row = mysql_fetch_array($result))
{
echo $row['Name'] . " " . $row['Dispersive'] . " " . $row['Polar'] . " " . $row['Hbonding'];
echo "<br />";
}
?>I thought that imploding the post would put the solvents into a useable format but I must be wrong - I would greatly appreciate any help I can get on this.
I would also like to use the coeffiecients returned for each checked solvent in a calculation - again I am a bit lost on what format they should be received from the mysql table.
Thank you for reading this, I hope you may be able to help me.