<?php require_once('Connections/receitas.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_Rsbusca = "-1";
if (isset($_POST['busca'])) {
  $colname_Rsbusca = $_POST['busca'];
}
mysql_select_db($database_receitas, $receitas);
$query_Rsbusca = sprintf("SELECT * FROM receitas WHERE titulo LIKE %s ORDER BY titulo ASC", GetSQLValueString("%" . $colname_Rsbusca . "%", "text"));
$Rsbusca = mysql_query($query_Rsbusca, $receitas) or die(mysql_error());
$row_Rsbusca = mysql_fetch_assoc($Rsbusca);
$totalRows_Rsbusca = "-1";
if (isset($_POST['busca'])) {
  $totalRows_Rsbusca = $_POST['busca'];
}

mysql_select_db($database_receitas, $receitas);
$query_Rsbusca = sprintf("SELECT * FROM receitas WHERE titulo = %s ORDER BY titulo ASC", GetSQLValueString($colname_Rsbusca, "text"));
$Rsbusca = mysql_query($query_Rsbusca, $receitas) or die(mysql_error());
$row_Rsbusca = mysql_fetch_assoc($Rsbusca);
$totalRows_Rsbusca = mysql_num_rows($Rsbusca);$colname_Rsbusca = "-1";
if (isset($_POST['buscar'])) {
  $colname_Rsbusca = $_POST['buscar'];
}
mysql_select_db($database_receitas, $receitas);
$query_Rsbusca = sprintf("SELECT * FROM receitas WHERE titulo = %s ORDER BY titulo ASC", GetSQLValueString($colname_Rsbusca, "text"));
$Rsbusca = mysql_query($query_Rsbusca, $receitas) or die(mysql_error());
$row_Rsbusca = mysql_fetch_assoc($Rsbusca);
$totalRows_Rsbusca = mysql_num_rows($Rsbusca);
?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sem t&iacute;tulo</title>
<link href="css/estilos.css" rel="stylesheet" type="text/css">


</head>

<body>
<div class="buscas">
  <table width="800" border="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><p><span><?php echo $row_Rsbusca['titulo']; ?></p>
      **********
      <p><?php echo nl2br ($row_Rsbusca['ingredientes']); ?></p>
       **********
      <p><?php echo nl2br ($row_Rsbusca['preparo']); ?></p>
    <br>
    </td>
  </tr>
</table>
</div>
</body>
</html>
<?php
mysql_free_result($Rsbusca);
?>
