Jump to content

[Resolvido] mysql_num_rows


PF2G

Recommended Posts

Boas,

estou a fazer um galeria de imagens usando .htaccess

gallery.php:

 // we get the current page from $_GET
 if (isset($_GET['page'])){
  $page_number = (int) $_GET['page'];
 }

 list($tax_name, $tax_id) = explode("-", $page);

 $result_content=mysql_query("SELECT * FROM album_images_lang WHERE id_image='".$tax_id."' lang='$current_lang' AND visivel=1 ORDER BY id ASC");
 $total_records = mysql_num_rows($result_content);

 // create the pagination class
 $pagination = new Pagination();
 $pagination->setLink($current_lang."/product/all?page=%s");
 $pagination->setPage($page_number);
 $pagination->setSize($size);
 $pagination->setTotalRecords($total_records);

 $result_content=mysql_query("SELECT * FROM album_images_lang WHERE id_image='".$tax_id."' lang='$current_lang' AND visivel=1 " . $pagination->getLimitSql());
 $row_content=mysql_fetch_assoc($result_content);

 $res_cont=mysql_query("SELECT * FROM album_images WHERE id='".$row_content['id_image']."' ORDER BY id ASC");
 $navigation = $pagination->create_links();

}
}
$num_rows_content = mysql_num_rows($res_cont);
$conta_rows_content = 1;
$content = "";

e este pedaço de código dá-me erro no mysql_num_row:

Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\wamp\www\www.iberveda.com\pages\gallery.php on line 67

Alguém me pode ajudar?

Obrigado,

PF2G

Edited by scorch
Adicionado Geshi.
Link to comment
Share on other sites

alguma destas chavetas fazem parte de algum if?

}
}
$num_rows_content = mysql_num_rows($res_cont);

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Link to comment
Share on other sites

Sim:

if($page == "all"){
$page_number = 1;

// how many records per page
$size = 8;

// we get the current page from $_GET
if (isset($_GET['page'])){
 $page_number = (int) $_GET['page'];
}
$result_content=mysql_query("SELECT * FROM album_images WHERE visivel=1 ORDER BY posicao ASC");
$total_records = mysql_num_rows($result_content);

$res_imagem=mysql_query("SELECT * FROM album_images_lang WHERE lang='".$current_lang."' AND id_image='".$total_records['id']."'");
$imagem=mysql_fetch_assoc($res_imagem);

// create the pagination class
$pagination = new Pagination();
$pagination->setLink($current_lang."/product/all?page=%s");
$pagination->setPage($page_number);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);

$result_content=mysql_query("SELECT * FROM album_lang WHERE titulo='estúdio' AND lang='$current_lang' AND visivel=1 ORDER BY posicao ASC " . $pagination->getLimitSql());

$navigation = $pagination->create_links();
}else{
if($clean_url[2]!="all"){
 $result_content=mysql_query("SELECT * FROM album_lang WHERE titulo='".$clean_url[2]."' AND lang='$current_lang' AND visivel=1 ORDER BY id ASSC");
}else{

 $page_number = 1;

 // how many records per page
 $size = 8;

 // we get the current page from $_GET
 if (isset($_GET['page'])){
  $page_number = (int) $_GET['page'];
 }

 list($tax_name, $tax_id) = explode("-", $page);

 $result_content=mysql_query("SELECT * FROM album_images_lang WHERE id_image='".$tax_id."' lang='$current_lang' AND visivel=1 ORDER BY id ASC");
 $total_records = mysql_num_rows($result_content);

 // create the pagination class
 $pagination = new Pagination();
 $pagination->setLink($current_lang."/product/all?page=%s");
 $pagination->setPage($page_number);
 $pagination->setSize($size);
 $pagination->setTotalRecords($total_records);

 $result_content=mysql_query("SELECT * FROM album_images_lang WHERE id_image='".$tax_id."' lang='$current_lang' AND visivel=1 " . $pagination->getLimitSql());

 $res_cont=mysql_query("SELECT * FROM album_images WHERE id='".$row_content['id_image']."' ORDER BY id ASC");
 $navigation = $pagination->create_links();

}
}
$num_rows_content = mysql_num_rows($res_cont);
$conta_rows_content = 1;
$content = "";

Link to comment
Share on other sites

se a pagina for igual a "all", entao o $res_cont nao ira' ser resultado da query, que significa que vai te dar aquele warning, passa isso para

$res_cont=mysql_query("SELECT * FROM album_images WHERE id='".$row_content['id_image']."' ORDER BY id ASC");

$navigation = $pagination->create_links();

$num_rows_content = mysql_num_rows($res_cont);

}

}

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Link to comment
Share on other sites

se a pagina for igual a "all", entao o $res_cont nao ira' ser resultado da query, que significa que vai te dar aquele warning, passa isso para

$res_cont=mysql_query("SELECT * FROM album_images WHERE id='".$row_content['id_image']."' ORDER BY id ASC");

$navigation = $pagination->create_links();

$num_rows_content = mysql_num_rows($res_cont);

}

}

Mas depois não o $num_row_content:

$res_cont=mysql_query("SELECT * FROM album_images WHERE id='".$row_content['id_image']."' ORDER BY id ASC");
$navigation = $pagination->create_links();
$num_rows_content = mysql_num_rows($res_cont);
}
}
$conta_rows_content = 1;
$content = "";
if($num_rows_content > 0 || $page == "all"){
Link to comment
Share on other sites

em vez de $num_rows_content > 0 mete:

if(isset($num_rows_content) || $page=="all")

EDIT: ou inicias o $num_rows_content a 0 antes do primeiro if!

Edited by pikax

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Link to comment
Share on other sites

em vez de $num_rows_content > 0 mete:

if(isset($num_rows_content) || $page=="all")

EDIT: ou inicias o $num_rows_content a 0 antes do primeiro if!

Ja não aparece o erro 🙂

Obrigado.

Ja agora podes-me explicar pq usaste o isset? Eu decorei a utilização do isset apenas no submit de forms, mas nunca percebi para que serve. :S

Cumprimentos,

PF2G

Link to comment
Share on other sites

o isset serve para ver se a variavel existe

Por muito mais que que estude só aprendo uma coisa, que ainda tenho muita coisa para aprender.

A beleza de um código está em decompor problemas complexos em pequenos blocos simples.

"learn how to do it manually first, then use the wizzy tool to save time."

"Kill the baby, don't be afraid of starting all over again. Fail soon, learn fast."

Link to comment
Share on other sites

Agora tenho o mesmo erro neste código, ja andei as voltas ver nomes errados e não vejo nada de mal:

$conta_rows_content = 1;
$content = "";
$num_rows_content=0;
if($num_rows_content || $page=="all"){
echo '<div class="content" id="page">
<div class="container">
<div class="interior_page" style="border-bottom:0px;">';
if($page == "all"){
$pageTitle="GALERIA";
}else{
if(isset($clean_url[3]) && $clean_url != ""){
$pageTitle = $row_content->titulo;
}else{
$result_tax_titulo = mysql_query("SELECT * FROM album_images WHERE id='". $tax_id."' LIMIT 0,1");
$row_tax_titulo = mysql_fetch_object($result_tax_titulo);

$pageTitle = $row_tax_titulo->title;
}
}
}

if ($num_rows_content > 1 || $page == "all" || !isset($clean_url[3])){

//Se existir mais que um produto apresenta a listagem de todos os existentes

echo '<div id="products">';
echo "<h1 class='title'>".$pageTitle."</h1>";

echo '<div class="produts_list">';

$count_products = 1;

while($row_products = mysql_fetch_assoc($result_content)){
$extra = unserialize(base64_decode($row_products->extra));

$clean_descricao = strip_tags($row_products->descricao);

$result_tax = mysql_query("SELECT * FROM album_images WHERE id='".$row_products->taxonomy_id."' LIMIT 0,1");
$row_tax = mysql_fetch_object($result_tax);

if($count_products == 2)
echo '<div class="product last">';
else
echo '<div class="product">';
if($extra['capa'] != "")
echo '<a href="'.$current_lang.'/product/'.$row_tax->link."-".$row_tax->id.'/'.$row_products->$clean_url.'">'.image_preset($extra['capa'], 'thumb_products', 'align="left"')."</a>";
echo '<label class="titulo"><a href="'.$current_lang.'/product/'.$row_tax->link."-".$row_tax->id.'/'.$row_products->url.'">'.$row_products->titulo.'</a></label>';
echo '<label class="tax"><a href="'.$current_lang.'/product/'.$row_tax->link."-".$row_tax->id.'">'.$row_tax->title.'</a></label>';

echo '<label class="descricao">'.substr($clean_descricao, 0 ,120);
if(strlen($clean_descricao) > 120)
echo "(...)";
echo '</label>';
echo '</div>';

if($count_products == 2)
$count_products = 1;
else
$count_products++;
}

O erro é no while:

while($row_products = mysql_fetch_assoc($result_content)){
Edited by PF2G
Link to comment
Share on other sites

Desculpa estava na parte de cima:

if($page == "all"){
$page_number = 1;

// how many records per page
$size = 8;

// we get the current page from $_GET
if (isset($_GET['page'])){
 $page_number = (int) $_GET['page'];
}
$result_content=mysql_query("SELECT * FROM album_images WHERE visivel=1 ORDER BY posicao ASC");
$total_records = mysql_num_rows($result_content);

$res_imagem=mysql_query("SELECT * FROM album_images_lang WHERE lang='".$current_lang."' AND id_image='".$total_records['id']."'");
$imagem=mysql_fetch_assoc($res_imagem);

// create the pagination class
$pagination = new Pagination();
$pagination->setLink($current_lang."/gallery/all?page=%s");
$pagination->setPage($page_number);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);

$result_content=mysql_query("SELECT * FROM album_lang WHERE titulo='estúdio' AND lang='$current_lang' AND visivel=1 ORDER BY posicao ASC " . $pagination->getLimitSql());

$navigation = $pagination->create_links();
}else{
if($clean_url[2]!="all"){
 $result_content=mysql_query("SELECT * FROM album_lang WHERE titulo='".$clean_url[2]."' AND lang='$current_lang' AND visivel=1 ORDER BY id ASSC");
}else{

 $page_number = 1;

 // how many records per page
 $size = 8;

 // we get the current page from $_GET
 if (isset($_GET['page'])){
  $page_number = (int) $_GET['page'];
 }

 list($tax_name, $tax_id) = explode("-", $page);

 $result_content=mysql_query("SELECT * FROM album_images_lang WHERE id_image='".$tax_id."' lang='$current_lang' AND visivel=1 ORDER BY id ASC");
 $total_records = mysql_num_rows($result_content);

 // create the pagination class
 $pagination = new Pagination();
 $pagination->setLink($current_lang."/gallery/all?page=%s");
 $pagination->setPage($page_number);
 $pagination->setSize($size);
 $pagination->setTotalRecords($total_records);

 $res_cont=mysql_query("SELECT * FROM album_images WHERE id='".$row_content['id_image']."' ORDER BY id ASC");
 $navigation = $pagination->create_links();
 $num_rows_content = mysql_num_rows($res_cont);
}
}
$conta_rows_content = 1;
$content = "";
$num_rows_content=0;
if($num_rows_content || $page=="all"){
echo '<div class="content" id="page">
 <div class="container">
  <div class="interior_page" style="border-bottom:0px;">';
   if($page == "all"){
    $pageTitle="GALERIA";
   }else{
    if(isset($clean_url[3]) && $clean_url != ""){
	 $pageTitle = $row_content->titulo;
    }else{
	 $result_tax_titulo = mysql_query("SELECT * FROM album_images WHERE id='". $tax_id."' LIMIT 0,1");
	 $row_tax_titulo = mysql_fetch_object($result_tax_titulo);

	 $pageTitle = $row_tax_titulo->title;
    }
   }
   }

   if ($num_rows_content > 1 || $page == "all" || !isset($clean_url[3])){

    //Se existir mais que um produto apresenta a listagem de todos os existentes

    echo '<div id="products">';
	 echo "<h1 class='title'>".$pageTitle."</h1>";

	 echo '<div class="produts_list">';

	 $count_products = 1;

	 while($row_products = mysql_fetch_assoc($result_content)){
	  $extra = unserialize(base64_decode($row_products->extra));

	  $clean_descricao = strip_tags($row_products->descricao);

	  $result_tax = mysql_query("SELECT * FROM album_images WHERE id='".$row_products->taxonomy_id."' LIMIT 0,1");
	  $row_tax = mysql_fetch_object($result_tax);

	  if($count_products == 2)
	   echo '<div class="product last">';
	  else
	   echo '<div class="product">';
	   if($extra['capa'] != "")
	    echo '<a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'/'.$row_products->$clean_url.'">'.image_preset($extra['capa'], 'thumb_products', 'align="left"')."</a>";
	   echo '<label class="titulo"><a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'/'.$row_products->url.'">'.$row_products->titulo.'</a></label>';
	   echo '<label class="tax"><a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'">'.$row_tax->title.'</a></label>';

	   echo '<label class="descricao">'.substr($clean_descricao, 0 ,120);
	    if(strlen($clean_descricao) > 120)
		 echo "(...)";
	   echo '</label>';
	  echo '</div>';

	  if($count_products == 2)
	   $count_products = 1;
	  else
	   $count_products++;
	 }
Link to comment
Share on other sites

com este código

$result_content=mysql_query("SELECT * FROM album_images WHERE visivel=1 ORDER BY posicao ASC");
$total_records = mysql_num_rows($result_content);

só posso concluir uma coisa ... tens erro de SQL.

adiciona a linha seguinte entre as duas linhas

echo mysql_error();
IRC : sim, é algo que ainda existe >> #p@p
Link to comment
Share on other sites

com este código

$result_content=mysql_query("SELECT * FROM album_images WHERE visivel=1 ORDER BY posicao ASC");
$total_records = mysql_num_rows($result_content);

só posso concluir uma coisa ... tens erro de SQL.

adiciona a linha seguinte entre as duas linhas

echo mysql_error();

Ei que estupidez. No inicio fartei-me de mudar 'posicao' para 'id' e escapou-me esse :S

Obrigado. Em principio ja deve estar 100%.

Link to comment
Share on other sites

Será que alguém me pode ajudar? É a primeira vez que mexo com codigo deste género (.htaccess) e está-me a confundir um pouco.

Eu quero criar uma galeria de imagens se o $clean_url[2]='all' aparecem as imagens todas se não aparecem as imagens cujo titulo = $clean_url[2].

Já não me está a dar erro nenhum, o unico problema é que nao aparecem as imagens:

<?php
if($page == "all"){
$page_number = 1;

// how many records per page
$size = 8;

// we get the current page from $_GET
if (isset($_GET['page'])){
 $page_number = (int) $_GET['page'];
}
$result_content=mysql_query("SELECT * FROM album_lang WHERE visivel=1 AND lang='".$current_lang."'");
$total_records = mysql_num_rows($result_content);

$result_image=mysql_query("SELECT * FROM album_images WHERE id_projecto='".$total_records['id_projecto']."'");
$total_images=mysql_num_rows($result_image);

$res_imagem=mysql_query("SELECT * FROM album_images_lang WHERE lang='".$current_lang."' AND id_image='".$total_images['id']."'");
$imagem=mysql_fetch_assoc($res_imagem);

// create the pagination class
$pagination = new Pagination();
$pagination->setLink($current_lang."/gallery/all?page=%s");
$pagination->setPage($page_number);
$pagination->setSize($size);
$pagination->setTotalRecords($total_records);

$result_content=mysql_query("SELECT * FROM album_lang WHERE titulo='estúdio' AND lang='$current_lang' AND visivel=1 ORDER BY id ASC " . $pagination->getLimitSql());
echo mysql_error();
$navigation = $pagination->create_links();
}else{
if($clean_url[2]!="all"){
 $result_content=mysql_query("SELECT * FROM album_lang WHERE titulo='".$clean_url[2]."' AND lang='$current_lang' AND visivel=1 ORDER BY id ASSC");
}else{

 $page_number = 1;

 // how many records per page
 $size = 8;

 // we get the current page from $_GET
 if (isset($_GET['page'])){
  $page_number = (int) $_GET['page'];
 }

 list($tax_name, $tax_id) = explode("-", $page);

 $result_content=mysql_query("SELECT * FROM album_images_lang WHERE id_image='".$tax_id."' lang='$current_lang' AND visivel=1 ORDER BY id ASC");

 $total_records = mysql_num_rows($result_content);

 // create the pagination class
 $pagination = new Pagination();
 $pagination->setLink($current_lang."/gallery/all?page=%s");
 $pagination->setPage($page_number);
 $pagination->setSize($size);
 $pagination->setTotalRecords($total_records);

 $res_cont=mysql_query("SELECT * FROM album_images WHERE id='".$row_content['id_image']."' ORDER BY id ASC");

 $navigation = $pagination->create_links();
 $num_rows_content = mysql_num_rows($res_cont);
}
}
$conta_rows_content = 1;
$content = "";
$num_rows_content=0;
if($num_rows_content || $page=="all"){
echo '<div class="content" id="page">
 <div class="container">
  <div class="interior_page" style="border-bottom:0px;">';
   if($page == "all"){
    $pageTitle="GALERIA";
   }else{
    if(isset($clean_url[3]) && $clean_url != ""){
	 $pageTitle = $row_content->titulo;
    }else{
	 $result_tax_titulo = mysql_query("SELECT * FROM album_images WHERE id='". $tax_id."' LIMIT 0,1");
	 $row_tax_titulo = mysql_fetch_object($result_tax_titulo);

	 $pageTitle = $row_tax_titulo->title;
    }
   }

   if ($num_rows_content > 1 || $page == "all" || !isset($clean_url[3])){

    //Se existir mais que um produto apresenta a listagem de todos os existentes

    echo '<div id="products">';
	 echo "<h1 class='title'>".$pageTitle."</h1>";

	 echo '<div class="produts_list">';

	 $count_products = 1;

	 while($row_products = mysql_fetch_assoc($result_content)){
	  $extra = unserialize(base64_decode($row_products->extra));

	  $clean_descricao = strip_tags($row_products->descricao);

	  $result_tax = mysql_query("SELECT * FROM album_images WHERE id='".$row_products->taxonomy_id."' LIMIT 0,1");
	  $row_tax = mysql_fetch_object($result_tax);

	  if($count_products == 2)
	   echo '<div class="product last">';
	  else
	   echo '<div class="product">';
	   if($extra['imagem'] != "")
	    echo '<a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'/'.$row_products->$clean_url.'">'.image_preset($extra['imagem'], 'thumb_products', 'align="left"')."</a>";
	   echo '<label class="titulo"><a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'/'.$row_products->url.'">'.$row_products->titulo.'</a></label>';
	   echo '<label class="tax"><a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'">'.$row_tax->title.'</a></label>';

	   echo '<label class="descricao">'.substr($clean_descricao, 0 ,120);
	    if(strlen($clean_descricao) > 120)
		 echo "(...)";
	   echo '</label>';
	  echo '</div>';

	  if($count_products == 2)
	   $count_products = 1;
	  else
	   $count_products++;

	 }

	 echo '<div class="clearfloat"></div>';
	 echo $navigation; // will draw our page navigation
	 echo '<div class="clearfloat"></div>';
	 echo '</div>';

    echo '</div>';

   }else{
    //Se apenas existir um produto mostra logo a página do mesmo e não a listagem

    $row_products = mysql_fetch_assoc($result_content);
    $extra = unserialize(base64_decode($row_products->extra));

    $pageTitle = $row_products->titulo;

    echo '<div id="products">';


	 echo '<div class="product_details">';
	  echo '<div class="extras">';
	   echo '<div class="images">';
	    if($extra['imagem'] != "")
	    echo '<a href="'.$extra['imagem'].'" rel="group" title="'.$pageTitle.'">'.image_preset($extra['imagem'], 'thumb_image', 'align="left" alt="'.$pageTitle.'"').'</a>';
	   echo '</div>';

	   $result_moresimages = mysql_query("SELECT ni.id, ni.imagem, ni.visivel, nil.titulo FROM `album_images` as ni, `album_images_lang` as nil
	   WHERE ni.id = nil.id_image AND nil.lang='$current_lang' AND ni.visivel=1 AND nil.visivel=1
	   AND ni.nid = ".$row_products->id." ORDER BY ni.posicao ASC");
	   if(mysql_num_rows($result_moresimages) > 0){
	    echo '<div class="more_images">';
		 echo '<ul>';
		 while($row_moreimages = mysql_fetch_object($result_moresimages)){
		  echo '<li><a href="'.$row_moreimages->imagem.'" rel="group" title="'.$row_moreimages->titulo.'">'.image_preset($row_moreimages->imagem, 'thumb_miniimage', 'align="left" alt="'.$row_moreimages->titulo.'"').'</a></li>';
		 }
		 echo '</ul>';
		 echo '<div class="clearfloat"></div>';
	    echo '</div>';
	   }

	   if($extra['anexo'] != "")
	    echo '<a href="'.$extra['anexo'].'" class="bt_maisinformacoes" target="_blank">DESCARREGUE O CATÁLOGO EM PDF</a>';


	  echo '</div>';

	  echo '<div class="descricao">';
	   echo "<h1 class='title'>".$pageTitle."</h1>";
	   echo $row_products->descricao;
	  echo '</div>';
	  echo '<div class="clearfloat"></div>';
	 echo '</div>';

    echo '</div>';

   }
   echo '<div class="clearfloat"></div>';
  echo  '</div>
   <div class="clearfloat"></div>';
echo  '</div>
 </div>';

}else{
header("Status: 404 Not Found");
header( "Location: ".$url."/".$current_lang."/pages/error/404" );
die();
}
?>
Link to comment
Share on other sites

só tens de "limpar" o valor quando for "all"

if ($clean_url[2] == "all") $clean_url[2] = "";
$result_content=mysql_query("SELECT * FROM album_lang WHERE titulo like '%".$clean_url[2]."%' AND lang='$current_lang' AND visivel=1 ORDER BY id ASSC");

nota : que alterei o modo de comparação do título, desta forma encontra registos do género >>

pesquisa : "abc"

registo válido : qweasdzxc

IRC : sim, é algo que ainda existe >> #p@p
Link to comment
Share on other sites

Damn it.

Continua sem me aparecer as imagens e a paginação por isso deve haver alguma query que nao esteja a passar...

<?php
if($clean_url[2] == "all"){
$clean_url[2]=="";
$page_number = 1;

// how many records per page
$size = 8;

// we get the current page from $_GET
if (isset($_GET['page'])){
 $page_number = (int) $_GET['page'];
}
$result_content=mysql_query("SELECT * FROM album_lang WHERE visivel=1 ORDER BY id_projecto ASC");
$total_records = mysql_num_rows($result_content);

$result_cont=mysql_query("SELECT * FROM album_images WHERE id_projecto='".$total_records['id_projecto']."'");
$records_cont=mysql_fetch_assoc($result_cont);

$res_imagem=mysql_query("SELECT * FROM album_images_lang WHERE titulo LIKE '% ".$clean_url[2]." %' AND lang='".$current_lang."' AND id='".$result_cont['id']."'");
$imagem=mysql_fetch_assoc($res_imagem);

// create the pagination class
$pagination = new Pagination();
$pagination->setLink($current_lang."/gallery/all?page=%s");
$pagination->setPage($page_number);
$pagination->setSize($size);
$pagination->setTotalRecords($imagem);

$result_content=mysql_query("SELECT * FROM album_lang WHERE titulo='estúdio' AND lang='$current_lang' AND visivel=1 ORDER BY id ASC " . $pagination->getLimitSql());
echo mysql_error();
$navigation = $pagination->create_links();
}else{
if($clean_url[2]!="all"){
 $result_content=mysql_query("SELECT * FROM album_lang WHERE titulo='".$clean_url[2]."' AND lang='$current_lang' AND visivel=1 ORDER BY id ASSC");
}else{

 $page_number = 1;

 // how many records per page
 $size = 8;

 // we get the current page from $_GET
 if (isset($_GET['page'])){
  $page_number = (int) $_GET['page'];
 }

 list($tax_name, $tax_id) = explode("-", $page);

 $result_content=mysql_query("SELECT * FROM album_images_lang WHERE id_image='".$tax_id."' lang='$current_lang' AND visivel=1 ORDER BY id ASC");

 $total_records = mysql_num_rows($result_content);

 // create the pagination class
 $pagination = new Pagination();
 $pagination->setLink($current_lang."/gallery/all?page=%s");
 $pagination->setPage($page_number);
 $pagination->setSize($size);
 $pagination->setTotalRecords($total_records);

 $res_cont=mysql_query("SELECT * FROM album_images WHERE id='".$row_content['id_image']."' ORDER BY id ASC");

 $navigation = $pagination->create_links();
 $num_rows_content = mysql_num_rows($res_cont);
}
}
$conta_rows_content = 1;
$content = "";
$num_rows_content=0;
if($num_rows_content || $page=="all"){
echo '<div class="content" id="page">
 <div class="container">
  <div class="interior_page" style="border-bottom:0px;">';
   if($page == "all"){
    $pageTitle="GALERIA";
   }else{
    if(isset($clean_url[3]) && $clean_url != ""){
	 $pageTitle = $row_content->titulo;
    }else{
	 $result_tax_titulo = mysql_query("SELECT * FROM album_images WHERE id='". $tax_id."' LIMIT 0,1");
	 $row_tax_titulo = mysql_fetch_object($result_tax_titulo);

	 $pageTitle = $row_tax_titulo->title;
    }
   }

   if ($num_rows_content > 1 || $page == "all" || !isset($clean_url[3])){

    //Se existir mais que um produto apresenta a listagem de todos os existentes

    echo '<div id="products">';
	 echo "<h1 class='title'>".$pageTitle."</h1>";

	 echo '<div class="produts_list">';

	 $count_products = 1;

	 while($row_products = mysql_fetch_assoc($result_content)){
	  $extra = unserialize(base64_decode($row_products->extra));

	  $clean_descricao = strip_tags($row_products->descricao);

	  $result_tax = mysql_query("SELECT * FROM album_images WHERE id='".$row_products->taxonomy_id."' LIMIT 0,1");
	  $row_tax = mysql_fetch_object($result_tax);

	  if($count_products == 2)
	   echo '<div class="product last">';
	  else
	   echo '<div class="product">';
	   if($extra['imagem'] != "")
	    echo '<a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'/'.$row_products->$clean_url.'">'.image_preset($extra['imagem'], 'thumb_products', 'align="left"')."</a>";
	   echo '<label class="titulo"><a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'/'.$row_products->url.'">'.$row_products->titulo.'</a></label>';
	   echo '<label class="tax"><a href="'.$current_lang.'/gallery/'.$row_tax->link."-".$row_tax->id.'">'.$row_tax->title.'</a></label>';

	   echo '<label class="descricao">'.substr($clean_descricao, 0 ,120);
	    if(strlen($clean_descricao) > 120)
		 echo "(...)";
	   echo '</label>';
	  echo '</div>';

	  if($count_products == 2)
	   $count_products = 1;
	  else
	   $count_products++;

	 }

	 echo '<div class="clearfloat"></div>';
	 echo $navigation; // will draw our page navigation
	 echo '<div class="clearfloat"></div>';
	 echo '</div>';

    echo '</div>';

   }else{
    //Se apenas existir um produto mostra logo a página do mesmo e não a listagem

    $row_products = mysql_fetch_assoc($result_content);
    $extra = unserialize(base64_decode($row_products->extra));

    $pageTitle = $row_products->titulo;

    echo '<div id="products">';


	 echo '<div class="product_details">';
	  echo '<div class="extras">';
	   echo '<div class="images">';
	    if($extra['imagem'] != "")
	    echo '<a href="'.$extra['imagem'].'" rel="group" title="'.$pageTitle.'">'.image_preset($extra['imagem'], 'thumb_image', 'align="left" alt="'.$pageTitle.'"').'</a>';
	   echo '</div>';

	   $result_moresimages = mysql_query("SELECT ni.id, ni.imagem, ni.visivel, nil.titulo FROM `album_images` as ni, `album_images_lang` as nil
	   WHERE ni.id = nil.id_image AND nil.lang='$current_lang' AND ni.visivel=1 AND nil.visivel=1
	   AND ni.nid = ".$row_products->id." ORDER BY ni.posicao ASC");
	   if(mysql_num_rows($result_moresimages) > 0){
	    echo '<div class="more_images">';
		 echo '<ul>';
		 while($row_moreimages = mysql_fetch_object($result_moresimages)){
		  echo '<li><a href="'.$row_moreimages->imagem.'" rel="group" title="'.$row_moreimages->titulo.'">'.image_preset($row_moreimages->imagem, 'thumb_miniimage', 'align="left" alt="'.$row_moreimages->titulo.'"').'</a></li>';
		 }
		 echo '</ul>';
		 echo '<div class="clearfloat"></div>';
	    echo '</div>';
	   }

	   if($extra['anexo'] != "")
	    echo '<a href="'.$extra['anexo'].'" class="bt_maisinformacoes" target="_blank">DESCARREGUE O CATÁLOGO EM PDF</a>';


	  echo '</div>';

	  echo '<div class="descricao">';
	   echo "<h1 class='title'>".$pageTitle."</h1>";
	   echo $row_products->descricao;
	  echo '</div>';
	  echo '<div class="clearfloat"></div>';
	 echo '</div>';

    echo '</div>';

   }
   echo '<div class="clearfloat"></div>';
  echo  '</div>
   <div class="clearfloat"></div>';
echo  '</div>
 </div>';

}else{
header("Status: 404 Not Found");
header( "Location: ".$url."/".$current_lang."/pages/error/404" );
die();
}
?>
Link to comment
Share on other sites

eu ja vi algo que não me agrada muito aqui

$total_records = mysql_num_rows($result_content);
$result_cont=mysql_query("SELECT * FROM album_images WHERE id_projecto='".$total_records['id_projecto']."'");

mas como é melhor ensinar a pescar que dar o peixinho ... adiciona estas linhas de código ao início do teu script

   error_reporting(E_ALL);
   ini_set('display_errors', '1');

depois le as linhas de erro/warning que aparece

corrige até que não apareça nenhuma

IRC : sim, é algo que ainda existe >> #p@p
Link to comment
Share on other sites

eu ja vi algo que não me agrada muito aqui

$total_records = mysql_num_rows($result_content);
$result_cont=mysql_query("SELECT * FROM album_images WHERE id_projecto='".$total_records['id_projecto']."'");

mas como é melhor ensinar a pescar que dar o peixinho ... adiciona estas linhas de código ao início do teu script

error_reporting(E_ALL);
ini_set('display_errors', '1');

depois le as linhas de erro/warning que aparece

corrige até que não apareça nenhuma

lamento desapontar-te mas não me esta a dar erro nenhum :S

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.