Below is my code
<form id="form1" name="holistic" method="post" action=""> <label>Treatment choice <select name="select" id="select"> <?php $con = connectToDatabase(); $sql = mysql_query("SELECT * FROM holistic ORDER BY holistic_id"); if (!$sql) { die('Could not query: ' .mysql_error()); }; while ( $info = mysql_fetch_assoc($sql)) { echo "<option name=".$info[holistic_id]." value=".$info[holistic_id].">".$info[treatment]."</optgroup>"; } echo "</select>"; echo "</label>"; echo "<input name='Go' type='submit' />"; echo "</form>" ?> <?php $selection_id = $_POST["holistic_id"]; $con = connectToDatabase(); $sql = mysql_query("SELECT * FROM holistic WHERE holistic_id=$selection"); if (!$sql) { die('Could not query: ' .mysql_error()); }; echo "<table>"; echo "<tr>"; while ($info = mysql_fetch_assoc($sql)) { echo "<td>".$info[description]."</td>"; echo "<td>".$info[cost]."</td>"; echo "<td>".$info[time]."</td>"; } echo "</tr>"; echo "</table>"; ?>
I would appreciate any help and advice on this as I am new to php.
The error I am getting is Could not query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1