NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [resolved] Downloads display thing..

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-19-2006, 07:37 AM THREAD STARTER               #1 (permalink)
New Member
Join Date: Dec 2006
Posts: 10
Catie is an unknown quantity at this point
 



Downloads display thing..


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

PHP Code:
<?php 

//MySQL connection variables 
$user="blahblah";  
$host="localhost";  
????: NamePros.com http://www.namepros.com/programming/270956-resolved-downloads-display-thing.html
$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"];  
????: NamePros.com http://www.namepros.com/showthread.php?t=270956
$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
Catie is offline  
Old 12-19-2006, 07:55 AM   #2 (permalink)
NamePros Regular
 
baxter's Avatar
Join Date: Apr 2006
Posts: 363
baxter is just really nicebaxter is just really nicebaxter is just really nicebaxter is just really nice
 


Ethan Allen Fund Save The Children
should this

PHP Code:
$preview=$row["preview"]; 
$dcounter=$dcounter["dcounter"]; 
$pcounter=$pcounter["pcounter"]; 
be

PHP Code:
$preview=$row["preview"]; 
$dcounter=$row["dcounter"]; 
????: NamePros.com http://www.namepros.com/showthread.php?t=270956
$pcounter=$row["pcounter"]; 
__________________
Canadian Domain Registrar Ready.ca
baxter is offline  
Old 12-19-2006, 09:16 AM   #3 (permalink)
NamePros Regular
 
Noobie's Avatar
Join Date: Feb 2006
Location: Montreal, Quebec, Canada
Posts: 324
Noobie is on a distinguished road
 



Originally Posted by baxter
should this

PHP Code:
$preview=$row["preview"]; 
????: NamePros.com http://www.namepros.com/showthread.php?t=270956
$dcounter=$dcounter["dcounter"]; 
$pcounter=$pcounter["pcounter"]; 
be

PHP Code:
$preview=$row["preview"]; 
$dcounter=$row["dcounter"]; 
$pcounter=$row["pcounter"]; 
Good eyes

give him some rep
__________________
Goldkey.com is a scam
What's your BMI? | Timestamp Generator
Noobie is offline  
Old 12-27-2006, 07:29 PM   #4 (permalink)
Account Closed
 
Alex.'s Avatar
Join Date: Nov 2006
Location: Uk
Posts: 601
Alex. is on a distinguished road
 


Ethan Allen Fund Third World Education
doesnt his script only print out 1 result?

sorry, i am novice and im very confused
Alex. is offline  
Old 12-27-2006, 07:43 PM   #5 (permalink)
Dan
Buy my domains.
 
Dan's Avatar
Join Date: Feb 2006
Posts: 2,796
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
 


Autism Autism Autism Autism Autism Autism Autism
No:

while ($row=mysql_fetch_array($result)) {
That somehow works for looping, although PHP has another function made for looping through results: mysql_fetch_assoc.
Dan is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:26 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger