<?php
// technocurve arc 3 php bv block1/3 start
$color1 = "#CCFFFF";
$color2 = "#FFFFFF";
$color = $color1;
// technocurve arc 3 php bv block1/3 end

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;
}
}
?>
<?php require_once('../Connections/conreceitas.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];

mysql_select_db($database_conreceitas, $conreceitas);
$query_receitas = "SELECT * FROM receitas ORDER BY titulo ASC";
$receitas = mysql_query($query_receitas, $conreceitas) or die(mysql_error());
$row_receitas = mysql_fetch_assoc($receitas);
$totalRows_receitas = mysql_num_rows($receitas);

$maxRows_receitas = 20;
$pageNum_receitas = 0;
if (isset($_GET['pageNum_receitas'])) {
  $pageNum_receitas = $_GET['pageNum_receitas'];
}
$startRow_receitas = $pageNum_receitas * $maxRows_receitas;

mysql_select_db($database_conreceitas, $conreceitas);
$query_receitas = "SELECT * FROM receitas ORDER BY titulo ASC";
$query_limit_receitas = sprintf("%s LIMIT %d, %d", $query_receitas, $startRow_receitas, $maxRows_receitas);
$receitas = mysql_query($query_limit_receitas, $conreceitas) or die(mysql_error());
$row_receitas = mysql_fetch_assoc($receitas);

if (isset($_GET['totalRows_receitas'])) {
  $totalRows_receitas = $_GET['totalRows_receitas'];
} else {
  $all_receitas = mysql_query($query_receitas);
  $totalRows_receitas = mysql_num_rows($all_receitas);
}
$totalPages_receitas = ceil($totalRows_receitas/

$queryString_receitas = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_receitas") == false && 
        stristr($param, "totalRows_receitas") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_receitas = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_receitas = sprintf("&totalRows_receitas=%d%s", $totalRows_receitas, $queryString_receitas);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="5">
  <tr>
    <td align="center" class="stilo"><span class="stilo24">UM COZINHEIRO E QUATRO ESFOMEADOS</span></td>
  </tr>
  <tr>
    <td align="center" class="stilo">RECEITAS</td>
  </tr>
  <tr>
    <td align="left" class="stilo2"><span class="stilo1">RECEITAS</span> &nbsp;<span class="stilo3"><?php echo ($startRow_receitas + 1) ?>&nbsp; À&nbsp; <?php echo min($startRow_receitas + $maxRows_receitas, $totalRows_receitas) ?> DE <?php echo $totalRows_receitas ?></span></td>
  </tr>
  <tr>
    <td align="left" bgcolor="#000099" class="stilo2">&nbsp;</td>
  </tr>
</table>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><?php do { ?>
      <table width="700" border="0" align="center" cellpadding="0" cellspacing="5">
        <tr <?php 
// technocurve arc 3 php bv block2/3 start
echo " style=\"background-color:$color\"";
// technocurve arc 3 php bv block2/3 end
?>>
          <td width="666"><a href="receita.php?id=<?php echo $row_receitas['id']; ?>" target="_parent" class="stilo1"><?php echo $row_receitas['titulo']; ?> <?php echo $row_receitas['autor']; ?></a></td>
        </tr>
        <?php 
// technocurve arc 3 php bv block3/3 start
if ($color == $color1) {
	$color = $color2;
} else {
	$color = $color1;
}
// technocurve arc 3 php bv block3/3 end
?>
      </table>
    <?php } while ($row_receitas = mysql_fetch_assoc($receitas)); ?></td>
  </tr>
</table>
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" align="center" bgcolor="#000099" class="stilo3">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="center" class="stilo3"><?php
for ($i=0; $i <= $totalPages_receitas; $i++) {
  $TFM_PagesEndCount = $i + 1;
  if($i != $pageNum_receitas) {
    printf('<a href="'."%s?pageNum_receitas=%d%s", $currentPage, $i, $queryString_receitas.'">'.$TFM_PagesEndCount."</a>");
  }else{
    echo("<b>$TFM_PagesEndCount</b>");
  }
  if($i != $totalPages_receitas) echo("  !  ");
}
 ?></td>
  </tr>
  <tr>
    <td align="center" class="stilo1">&nbsp;</td>
    <td align="center">&nbsp;</td>
  </tr>
  <tr>
    <td width="223" align="center" class="stilo1"><a href="inicio.php" target="_parent">INÍCIO</a></td>
    <td width="270" align="center"><a href="javascript:window.close()" class="stilo1" onmouseover="window.status='FECHAR';return true" onmouseout="window.status='';return true">FECHAR</a></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($receitas);
?>
