Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I know you might think that this should be in the database forum but I think it is more of a php question. I have managed to obtain the numbers I need from a mysql database but now I have no idea how to perform the calculation I want on them.
The html is very simple and lets a user select which solvents they want via a checklist.
[syntax="html"]
<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']);
}
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
IN('{$_POST['Solvents']}')");
while($row = mysql_fetch_array($result))
{
echo $row['Name'] . " " . $row['Dispersive'] . " " . $row['Polar'] . " " .
$row['Hbonding'];
echo "<br />";
}
?>I would be very grateful for an answer to this, thank you for your time.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]