Click to See Complete Forum and Search --> : Send To The Right Arquive


rogernem
November 11th, 2004, 03:49 PM
This is my code:


<?
include("toing_conexao.php");

$sql="SELECT * FROM produtos WHERE menuitem = '$menuitem' ORDER BY nomeproduto ASC";
$result=mysql_query($sql,$conn);

echo "<b><font face=verdana size=2>L I S T A&nbsp;&nbsp;&nbsp;D A&nbsp;&nbsp;&nbsp;C A T E G O R I A : $menuitem </B></font>";
echo "<br><br>";
echo "<table width=100% border=2 align=center cellpadding=0 cellspacing=0>";
echo "<tr>";

while ($row = mysql_fetch_array($result)) {
$id = $row["id_prod"];
$menuitem = $row["menuitem"];
//recebe o menuitem em x e deixa tudo em minusculo
$dir = $menuitem;
$dir = strtolower($dir);

$nomeproduto = $row["nomeproduto"];
$s = $nomeproduto;

//ta diminuindo o nomeproduto para tudo minuscula $s e depois deixa so a 1a letra em maiuc $s1
$s = strtolower($s);
$s1 = $s;
$s1 = ucfirst($s1);
$arq = $s1;

// substitui o " " por um espaco
$s = str_replace(" ","$&nbsp;",$s);

//recebe o nomeproduto em x e deixa tudo em minusculo
$arq = $s;
$arq = strtolower($arq);

$extensao = $row["extensao"];
$imagem = $row["imagem"];

echo "<td width=200><img src=imagens\\$menuitem\\$imagem></td> <td><a href=toing_principal.php?arquivo=downloads/$dir/$arq.$extensao >$s1</a></td> ";
echo "</tr>";

}

echo "</table>";
echo "<br>";
?>
<?

$con = mysql_connect('localhost','admin','admin');
mysql_select_db('toing');


$arquivo = $_GET['arquivo'];
$consulta = "SELECT arquivo,hits FROM contador WHERE arquivo='$arquivo'";
$res = mysql_query($consulta,$con);
/*
certificar se o arquivo já foi clicado alguma vez. Se o arquivo ainda
não consta em nossa tabela, vamos inserir um novo registro, caso contrário
vamos somar um hit ao registro existente
*/

if ($saida = mysql_fetch_array($res)) { // registro existe
$hit = ++$saida[1]; // some 1 (um) ao número de cliques
$update = "UPDATE contador SET hits=$hit WHERE arquivo='$arquivo'";
mysql_query($update,$con); // atualize o registro
} else {
$insert = "INSERT INTO contador (arquivo) VALUES ('$arquivo')";
mysql_query($insert,$con); // insira o novo arquivo na tabela. O valor padrão
// de hit é 1 (um)
}

?>



In the toing_principal.php I have the following:

Motorola with link -> downloads/wallpapers/motorola.jpg
tim with link -> downloads/wallpapers/tim.jpg

Full LINK:
http://localhost/toing/02-menu/toing_principal?arquivo=downloads/wallpapers/motorola.jpg

The counter is working fine and add 1 if i click some link but its
NOT sending to where it should go: -> downloads/wallpapers/motorola.jpg

How can I do that??
I think its not understanding this: toing_principal?arquivo=downloads/wallpapers/motorola.jpg

Thank you!!

Viper_SB
November 12th, 2004, 01:01 AM
if I understand you right you are wanting to redirect after adding to the counter?
if so then use header() (www.php.net/header) for example

header('Location: http://www.mysite.com/myfile.jpg');

rogernem
November 12th, 2004, 08:19 PM
That's right
I will try that.
tkz