Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP > PHP Application Design
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Nov 11, 2004, 14:19   #1
rogernem
SitePoint Member
 
Join Date: Nov 2004
Location: sao paulo
Posts: 15
Angry Send To The Right Arquive

This is my code:

PHP 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?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...s/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!!
rogernem is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 22:04.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved