Código PHP:
<form method="post" action="buscar2.php">
<select name="metode" size="1">
<option value="row_nombre">nombre</option>
<option value="row_apellido">apellido</option>
</select>
<input type="text" name="search" size="25">
<input type="submit" value="Buscar">
</form>
Código PHP:
<?
$hostname = "localhost"; // Usually localhost.
$username = "aaaaa"; // If you have no username, leave this space empty.
$password = "eeee"; // The same applies here.
$usertable = "prueba"; // This is the table you made.
$dbName = "xxxxxxx"; // This is the main database you connect to.
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
@mysql_select_db( "$dbName") or die( "Unable to select database");
?>
<?
//error message (not found message)
$XX = "No Record Found";
$result = mysql_query("SELECT * FROM prueba WHERE $metode LIKE '%$search%' LIMIT 0, 30 ");
while ($row = mysql_fetch_row($result))
{
$nombre=$row["row_nombre"];
$apellido=$row["row_apellido"];
$dni=$row["row_dni"];
print ("this is for $id, and this print the nombre end so on...");
}
//below this is the function for no record!!
if (!$nombre)
{
print ("$XX");
}
//end
?>
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in buscar2.php on line 16.
Si alguien tiene la solución le agradeceria en que me haga saber, gracias.