Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

spankao

Retirar ação ramdomico dos banners

Recommended Posts

Galera tudo bom ? Estou com um problema, em um site existem 4 banners, e eles estão aleatórios, cada vez que entro no site

ele abre em uma determinada posição. alguem poderia alterar o código abaixo pra mim, deixando o banner estático, sem esse

sorteio ramdomico.

 

 

 

<div id="homeHighligth">

	<div id="highligth">

		<div align="center"><a href="http://www.meusite.com.br/?p=product">

        <?php

		include_once("class/feature/feature.php");

		$objFeature = New Feature;

		$arr = $objFeature->GetBySize(1);

		$total = TotalRows($arr);

		if ($total > 0) {		

			$url = mysql_result($arr, 0, "url");

			

			echo "<img src='$url' style='border:0;width:470px;height:187px;'/></a>";

		}

?>		

		</a></div>

  </div>

	<br />

	<div class="highligthMini" style="float:left;">

	  <div align="center"><a href="http://www.meusite.com.br/?p=channels">

<?php

		include_once("class/feature/feature.php");

		

		$objFeature = New Feature;

		$arrP = $objFeature->GetBySize(0);

		$totalP = TotalRows($arr);

		if ($totalP > 0) {		

			$url = mysql_result($arrP, 0, "url");

	

			echo "<img src='$url' style='border:0;width:222px;height:150px;'/></a>";

		}

?>			  

	  </a></div>

	</div>

	<div class="highligthMini" style="margin-left:245px;">

	  <div align="center"><a href="http://www.meusite.com.br/?p=beaclient&sec=1">

<?php

		//include_once("class/feature/feature.php");

		

		//$objFeature = New Feature;

		//$arr = $objFeature->GetBySize(0);

		//$total = TotalRows($arr);

		if ($totalP > 0) {		

			$url = mysql_result($arrP, 1, "url");

			

			echo "<img src='$url' style='border:0;width:222px;height:150px;'/></a>";

		}

?>			  

		</a></div>

	</div>

	<br />

	<div id="highligth">

	  <div align="center"><a href="http://www.meusite.com.br/?p=channels">

<?php

		//include_once("class/feature/feature.php");

		

		//$objFeature = New Feature;

		//$arr = $objFeature->GetBySize(1);

		//$total = TotalRows($arr);

		if ($total > 1) {		

			$url = mysql_result($arr, 1, "url");

			

			echo "<img src='$url' style='border:0;width:470px;height:187px;'/></a>";

		}

?>		

Compartilhar este post


Link para o post
Compartilhar em outros sites

Poste o conteudo deste arquivo:

class/feature/feature.php

Compartilhar este post


Link para o post
Compartilhar em outros sites

Poste o conteudo deste arquivo:

class/feature/feature.php

 

 

 

 

 

Ai está o Feature.php

<?PHP	
	class Feature
	{
		function Get()
		{
			$objConexao = new Conexao; 
			$conexao = $objConexao->Conectar();	
	
			$query = "SELECT id, name, url, idchannel, islarge FROM feature ORDER BY name ";

			return mysql_query($query, $conexao);
		}

		function GetBySize($islarge)
		{
			$objConexao = new Conexao; 
			$conexao = $objConexao->Conectar();	
	
			$query = "SELECT id, name, url, idchannel, islarge FROM feature WHERE islarge=".$islarge." ORDER BY RAND() LIMIT 2";
	
			return mysql_query($query, $conexao);
		}

		function GetByID($id)
		{
			$objConexao = new Conexao; 
			$conexao = $objConexao->Conectar();	
	
			$query = "SELECT id, name, url, idchannel, islarge FROM feature WHERE id=".$id;
	
			return mysql_query($query, $conexao);
		}
		
		function Delete($id)
		{
			$objConexao = new Conexao; 
			$conexao = $objConexao->Conectar();	
			
			$url = mysql_result($this->GetByID($id), 0, "url");
			unlink($url);
			
			$query = "DELETE FROM feature WHERE id=".$id;
	
			return mysql_query($query, $conexao);
		}

		function Update($id, $name, $idchannel, $url, $islarge)
		{
			$objConexao = new Conexao; 
			$conexao = $objConexao->Conectar();	

			$query = "UPDATE feature SET name ='".$name."',
				  idchannel=".$idchannel.",
				  url='".$url."',
				  islarge=".$islarge."
				  WHERE id=".$id;

			return mysql_query($query, $conexao);
		}

		function Insert($name, $idchannel, $url, $islarge)
		{
			$objConexao = new Conexao; 
			$conexao = $objConexao->Conectar();	

			$query = "INSERT INTO feature (name, idchannel, url, islarge) VALUES('".$name."',".$idchannel.",'".$url."',".$islarge.")";

			return mysql_query($query, $conexao);
		}
		
		function InsertImage($id, $url)
		{
			$objConexao = new Conexao; 
			$conexao = $objConexao->Conectar();	

			$query = "UPDATE feature SET
			url='".$url."'
			WHERE id=".$id;

			return mysql_query($query, $conexao);
		}

	}	
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olha o random ali.. é só alterar:

function GetBySize($islarge)
                {
                        $objConexao = new Conexao; 
                        $conexao = $objConexao->Conectar();     
        
                        $query = "SELECT id, name, url, idchannel, islarge FROM feature WHERE islarge=".$islarge." ORDER BY RAND() LIMIT 2";
        
                        return mysql_query($query, $conexao);
                }
por:

function GetBySize($islarge)
                {
                        $objConexao = new Conexao; 
                        $conexao = $objConexao->Conectar();     
        
                        //$query = "SELECT id, name, url, idchannel, islarge FROM feature WHERE islarge=".$islarge." ORDER BY RAND() LIMIT 2";
                        $query = "SELECT id, name, url, idchannel, islarge FROM feature WHERE islarge=".$islarge." LIMIT 2";
        
                        return mysql_query($query, $conexao);
                }
Ou você pode trocar o ORDER BY, ordenando pelo id, name, url..

Dessa forma que postei, vai listar pela ordem de cadastro.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.