Unstoppable Domains โ€” Get your daily AI drops report

Some small sql help

SpaceshipSpaceship
Watch

Gandhi

Established Member
Impact
47
Well just started www.templatesurge.com and as you will notice at top right under the big banner you will see
Total Templates: 31 Total Downloads: 18 Total Tutorials: 17 Users Online: 1 user online

What I want is for the Total Templates, Downloads, to update by it self, by getting the info from the sql db. Anyone know how to do this, I was told that it was easy, but I dont know how to do it.


So please if anyone can help it would be appreciated. :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
Yes, would be fairly easy.

Would need to know your database structure to give you the exact code for it...

But, let's say your template table was for example:

Code:
CREATE TABLE templates (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
author VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);

Total templates:
PHP:
<?php

$query = mysql_query("SELECT COUNT(id) AS tpl_count FROM templates") or die(mysql_error());
$numtemplates = mysql_fetch_assoc($query);
$numtemplates = $numtemplates['tpl_count'];

echo $numtemplates;

?>

and could be something similar for the others..
 
0
•••
Thanks for the code, really appreciate it :D

When I enterted the code I got this error

PHP:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'wwwtemp'@'localhost' (using password: NO) in /home2/wwwtemp/public_html/index.php on line 78

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/wwwtemp/public_html/index.php on line 78
Access denied for user 'wwwtemp'@'localhost' (using password: NO)
 
0
•••
looking at those errors it looks like you are not actually connected to the database yet.
 
0
•••
2007 said:
Thanks for the code, really appreciate it :D

When I enterted the code I got this error

PHP:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'wwwtemp'@'localhost' (using password: NO) in /home2/wwwtemp/public_html/index.php on line 78

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home2/wwwtemp/public_html/index.php on line 78
Access denied for user 'wwwtemp'@'localhost' (using password: NO)



Those errors are saying your trying to connect to the database with out a password, i would suggestion you check the mysql_connect/ mysql_pconnection function to make sure there's a password in there, and if your storing the password in a varible, that the varible is spelt the same in all places (it's a common problem even out experinced dev team at work suffer from .. =) )
 
0
•••
At this to the top if you do not have a config page,
<?

$dbhost = "localhost"; // database host, most of the time localhost
$dbuser = "username"; // database user
$dbpass = "pass"; // database password
$dbname = "dbname"; // database name

// DO NOT EDIT
mysql_connect("$dbhost","$dbuser","$dbpass");
mysql_select_db("$dbname");

?>

That will connect for you, else do an include once with your php config file
 
0
•••
CatchedCatched
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back