Downloads display thing...

This is a discussion on "Downloads display thing..." within the PHP Forum section. This forum, and the thread "Downloads display thing... are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 19th, 2006, 13:31
New Member
Join Date: Dec 2006
Location: Finland
Age: 19
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Downloads display thing...

Hello again! I store my graphics in a MySQL database and this is the code I'm using to display them on my page:

PHP: Select all

 <?php 

//MySQL connection variables 
$user="blahblah";  
$host="localhost";  
$password="blahblah";  
$database="blahblahblah";  
$connection mysql_connect($host,$user,$password)  
or die (
"couldn't connect to server"); $db mysql_select_db($database,$connection)  
or die (
"Couldn't select database");  

//Which mySQL table to select from and in what order 
$query "select * from `layouts` order by id desc";  

$result mysql_query($query$connection) or die ("Could not execute query : $query ." mysql_error());  
$rows mysql_num_rows($result); 
if (
$rows=="0") { echo "No layouts found."; } 


//Gets and assigns variables to array 
while ($row=mysql_fetch_array($result)) {  
$id=$row["id"];  
$title=$row["title"];  
$artist=$row["artist"];  
$artisturl=$row["artisturl"];   
$type=$row["type"];  
$size=$row["size"];  
$date=$row["date"];  
$previewimage=$row["previewimage"]; 
$download=$row["download"];  
$preview=$row["preview"]; 
$dcounter=$dcounter["dcounter"]; 
$pcounter=$pcounter["pcounter"];  

//Prints out results 
echo "<table id=\"box_top\"><tr> 
<tr><td> 
<b>$title</b> 
</td> 
</tr> 
</table> 
     
<table id=\"box\"> 
<tr> 
<td valign=\"top\"> 
<img src=\"$previewimage\" width=\"160\" height=\"110\" border=\"0\" alt=\"\"> 
</td>  
<td valign=\"top\" width=\"170\"> 
<b>Added</b>: $date 
<br><b>Type</b>: $type 
<br><b>Size</b>: $size 
<br><b>Designer</b>: <a href=\"$artisturl\" target=\"_blank\">$artist</a> 
<br><b>Previews</b>: $pcounter 
<br><b>Downloads</b>: $dcounter 
<br><br> 
<a href=\"$preview\"><b>Preview</b></a> &nbsp; <a href=\"$download\"><b>Download</b></a> 
</td> 
</tr> 
</table><br>"



?>
$dcounter=$dcounter["dcounter"]; and $pcounter=$pcounter["pcounter"]; should count the downloads/previews and $pcounter and $dcounter should display them? So, the problem is it won't display the number of the downloads/previews. I know I'm doing something wrong, but I don't know what.

Anyone knows?

By the way, maybe I'm doing something wrong in phpMyAdmin? Both dcounter and pcounter are set to VARCHAR(5) not null Default: 0
Reply With Quote

  #2 (permalink)  
Old Dec 19th, 2006, 15:28
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Downloads display thing...

Me thinks the problem is here:
Code: Select all
$dcounter=$dcounter["dcounter"]; 
$pcounter=$pcounter["pcounter"]; 
Should not the variable immediately to the right of = be $row?
Reply With Quote
  #3 (permalink)  
Old Dec 19th, 2006, 18:04
New Member
Join Date: Dec 2006
Location: Finland
Age: 19
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Downloads display thing...

Wow! Thanks so much! But I have another problem now, it won't count the downloads/previews. Do you know what it can be?
Reply With Quote
  #4 (permalink)  
Old Dec 19th, 2006, 22:41
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Downloads display thing...

Even with your code corrected, it wont count anything. It is just retrieving values from the database.

You need to be looking at the code that should be incrementing those values whenever a download takes place.
Reply With Quote
  #5 (permalink)  
Old Dec 20th, 2006, 11:46
New Member
Join Date: Dec 2006
Location: Finland
Age: 19
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Downloads display thing...

Do you know what code I need? Or at least what should I look for?
Thanks again!
Reply With Quote
  #6 (permalink)  
Old Dec 20th, 2006, 23:14
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Downloads display thing...

I'm guessing that the code you have shown us thus far is not yours, original that is. Is that a fair guess?

Is this all the code you have?
Reply With Quote
  #7 (permalink)  
Old Dec 21st, 2006, 13:52
New Member
Join Date: Dec 2006
Location: Finland
Age: 19
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Downloads display thing...

Of course it isn't mine. (Is it a problem?) It's from this:
http://seabreezed.org/index.php?show...&page=layoutdb

tutorial and it's all the code I have.
Reply With Quote
  #8 (permalink)  
Old Dec 21st, 2006, 14:46
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Downloads display thing...

No, it's not a problem.

What do you mean by "count"? That variable is just a number that's stored in the database, it doesn't do any calculations.
Reply With Quote
  #9 (permalink)  
Old Dec 21st, 2006, 17:03
New Member
Join Date: Dec 2006
Location: Finland
Age: 19
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Downloads display thing...

Well for example if there are 10 downloads and you click on the download link it says 11. It shows how many times a file has been downloaded. Do you know how to make it count how many times a link has been clicked, because it only shows the number I put in the database?
Reply With Quote
  #10 (permalink)  
Old Dec 21st, 2006, 22:18
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Downloads display thing...

You need to have some code somewhere, hat every time the download link is clicked, this code is activated and it incremente the value in the database.

You will need to use and sql update script.
Reply With Quote
Reply

Tags
mysql, php

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i add downloads monstermunch Starting Out 2 Feb 28th, 2007 23:50
HTTP and FTP Downloads EdgeWalker Web Page Design 4 Feb 15th, 2007 19:35
looking for a cms that easily allows downloads saltedm8 Other Programming Languages 6 Dec 14th, 2006 11:03
How to accomplish automated downloads? aarganesh Classic ASP 1 Jun 12th, 2005 19:44
Downloads Dr.K Web Page Design 3 May 19th, 2005 18:08


All times are GMT. The time now is 01:54.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43