I get an error when fetching data from a MySQL database using PHP.
Undefined variable: result in C:\wamp\www\mbdb\Biomarkerresult1.php on line 20
mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\wamp\www\mbdb\Biomarkerresult1.php on line 20
My dropdown list coding:
<select name="names" value="name">
<option value="Biomarker">Select a Biomarker</option>
<option value="Diagnostic">Diagnostic</option>
<option value="Prognsotic">Prognostic</option>
<option value="Predictive">Predictive</option>
Here is displaying data:
<?php
$con=mysqli_connect('localhost','root','','mbdb');
if(mysqli_errno($con))
{
echo "Can't Connect to mySQL:".mysqli_connect_error();
}
if(isset($_POST['names']))
{
$name = $_POST['names'];
$fetch="SELECT * FROM metabolites WHERE Biomarker_Category = '".$name."'";
$result = mysqli_query($con,$fetch);
}
while($row=mysqli_fetch_array($result))
{
//-----
}
Can anyone help me with this?