Hello
Recently developed a form called doctors. Then develop an application in php called busquedadoctores, a report to display data in tabular form. The application is based on two combo box, 1) to find the specialty and the other to find the city and give me a result which appears in the doctor's name, address, specialty, state, ect in tabular form. When I insert the data into the form I get the following error:
Warning: mysql_query () Expects parameter 1 to be string, Given resource in / home / zonamedi / public_html / busquedadoctores.php on line 55
Error getting data
The line 55 is $result = mysql_query ($dbcon, $query) or die ('error getting data');
The web address is:
The code to use is:
<html>
<head>
<title>Búsqueda de doctores</title>
<style type="text/css">
table {
background-color: #fcf;
}
th {
width: 150px;
text-align: left;
}
</style>
</head>
<body>
<h1>Búsqueda de doctores</h1>
<form method="post" action="busquedadoctores.php">
<input type="hidden" name="submitted" value="true" />
<label>Busqueda por especialidad:
<select name="especialidad">
<option value="Alergista e Inmunología">Alergista e Inmunología</option>
<option value="Anestesiólogo">Anestesiólogo</option>
<option value="Cardiólogo">Cardiólogo</option>
<option value="Cirujano">Cirujano</option>
<option value="Cirujano cardiovascular">Cirujano cardiovascular</option>
<option value="Cirujano maxilofacial">Cirujano maxilofacial</option>
<option value="Cirujano plástico">Cirujano plástico</option>
</select>
</label>
<label>Busqueda por pueblo:
<select name="pueblo">
<option value="Adjuntas">Adjuntas</option>
<option value="Aguada">Aguada</option>
<option value="Aguadilla">Aguadilla</option>
<input type="submit" />
</form>
<?php
if (isset($_POST['submitted'])) {
//connect database
include('connect.php');
$especialidad = $_POST['especialidad'];
$pueblo = $_POST['pueblo'];
$query = ("SELECT * FROM doctores WHERE $especialidad LIKE '%". $pueblo."%'");
$result = mysql_query($dbcon, $query) or die('error getting data');
$num_rows = mysql_num_rows($result);
echo "$num_rows result found";
echo "<table>";
echo "<tr> <th>Nombre</th> <th>Epecialidad</th> <th>Direccion</tr>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr><td>";
echo $row['NOMBRE'];
echo "</td><td>";
echo $row['ESPECIALIDAD'];
echo "</td><td>";
echo $row['DIRECCION'];
echo "</td></tr>";
}
echo "</table>";
}
?>
</body>
</html>
thanks for any help
Recently developed a form called doctors. Then develop an application in php called busquedadoctores, a report to display data in tabular form. The application is based on two combo box, 1) to find the specialty and the other to find the city and give me a result which appears in the doctor's name, address, specialty, state, ect in tabular form. When I insert the data into the form I get the following error:
Warning: mysql_query () Expects parameter 1 to be string, Given resource in / home / zonamedi / public_html / busquedadoctores.php on line 55
Error getting data
The line 55 is $result = mysql_query ($dbcon, $query) or die ('error getting data');
The web address is:
The code to use is:
<html>
<head>
<title>Búsqueda de doctores</title>
<style type="text/css">
table {
background-color: #fcf;
}
th {
width: 150px;
text-align: left;
}
</style>
</head>
<body>
<h1>Búsqueda de doctores</h1>
<form method="post" action="busquedadoctores.php">
<input type="hidden" name="submitted" value="true" />
<label>Busqueda por especialidad:
<select name="especialidad">
<option value="Alergista e Inmunología">Alergista e Inmunología</option>
<option value="Anestesiólogo">Anestesiólogo</option>
<option value="Cardiólogo">Cardiólogo</option>
<option value="Cirujano">Cirujano</option>
<option value="Cirujano cardiovascular">Cirujano cardiovascular</option>
<option value="Cirujano maxilofacial">Cirujano maxilofacial</option>
<option value="Cirujano plástico">Cirujano plástico</option>
</select>
</label>
<label>Busqueda por pueblo:
<select name="pueblo">
<option value="Adjuntas">Adjuntas</option>
<option value="Aguada">Aguada</option>
<option value="Aguadilla">Aguadilla</option>
<input type="submit" />
</form>
<?php
if (isset($_POST['submitted'])) {
//connect database
include('connect.php');
$especialidad = $_POST['especialidad'];
$pueblo = $_POST['pueblo'];
$query = ("SELECT * FROM doctores WHERE $especialidad LIKE '%". $pueblo."%'");
$result = mysql_query($dbcon, $query) or die('error getting data');
$num_rows = mysql_num_rows($result);
echo "$num_rows result found";
echo "<table>";
echo "<tr> <th>Nombre</th> <th>Epecialidad</th> <th>Direccion</tr>";
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr><td>";
echo $row['NOMBRE'];
echo "</td><td>";
echo $row['ESPECIALIDAD'];
echo "</td><td>";
echo $row['DIRECCION'];
echo "</td></tr>";
}
echo "</table>";
}
?>
</body>
</html>
thanks for any help
Comment