SEND TO THE RIGHT ARQUIVE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rogernem
Forum Newbie
Posts: 8
Joined: Mon Nov 08, 2004 6:03 am

SEND TO THE RIGHT ARQUIVE

Post by rogernem »

This is my code:

Code: Select all

їphp]
<?
	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)) &#123;
	$id = $row&#1111;"id_prod"];
    $menuitem  = $row&#1111;"menuitem"];
    //recebe o menuitem em x e deixa tudo em minusculo
	$dir = $menuitem;
	$dir = strtolower($dir);
	
    $nomeproduto = $row&#1111;"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&#1111;"extensao"];
    $imagem = $row&#1111;"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>";
	 
	&#125;

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

	$con = mysql_connect('localhost','admin','admin');
	mysql_select_db('toing');
	
	
	$arquivo = $_GET&#1111;'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)) &#123; // registro existe
	    $hit = ++$saida&#1111;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
	&#125; else &#123;
	    $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)
	&#125;

?>
&#1111;/php]
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_pr ... torola.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!!
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

If I understand your code right this part

Code: Select all

echo "&lt;td width=200&gt;&lt;img src=imagens\\$menuitem\\$imagem&gt;&lt;/td&gt;  &lt;td&gt;&lt;a href=toing_principal?arquivo=downloads/$dir/$arq.$extensao &gt;$s1&lt;/a&gt;&lt;/td&gt; ";
   echo "&lt;/tr&gt;";
doesn't seem to be quite right, try

Code: Select all

<?php
 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>"; 
?>
as I believe that a href tag likes in values in " "
also make sure that your path is correct to the right file as I know that has messed me up before.
rogernem
Forum Newbie
Posts: 8
Joined: Mon Nov 08, 2004 6:03 am

Post by rogernem »

i will try that
tkz
;)
rogernem
Forum Newbie
Posts: 8
Joined: Mon Nov 08, 2004 6:03 am

Post by rogernem »

didnt work

Thats getting hard!! :oops:
Post Reply