Show Total Image Count on External Website
inebriated
Joined: 2012-07-05
Posts: 11 |
![]() |
Hi there, I have my gallery installed on a subdomain of an already popular site, for example gallery.mysite.com What I would like to acheive is to display the total number of images in the gallery on my main domain mysite.com Im fairly competent in PHP and MySQL and was thinking of just connecting to the gallery DB from the main site and counting the image count somehow (havent looked at db structure yet) and then echo'ing it out. Is this the best way to go about this or is there an alternative solution? Kind Regards |
|
floridave
![]()
Joined: 2003-12-22
Posts: 27300 |
![]() |
I would think that would be the best and only solution. Dave |
|
inebriated
Joined: 2012-07-05
Posts: 11 |
![]() |
Done and works a charm, Here is what I did : <?php mysql_select_db("MYDATABASE", $con); $result = mysql_query("select count(1) -1 FROM items"); $total = $row[0]; mysql_close($con); Works fine for me, although I read that I should use mySQLi instead of just mySQL Or even better, could I include the gallerys installation to establish the database connection? if so which files do I need to include? (i dont like the idea of including the user/pass in the file itself) |
|
spags
Joined: 2010-03-26
Posts: 120 |
![]() |
You need to amend your SQL statement because you are also including the count of the number of albums in the gallery as well. Sorry I don't remember exact column names and values (you might need to hunt around the database a bit to check), but it would be something like this: select count(1)-1 from items where type="photo" There are also "movie" item types as well. Maybe you are better off selecting where the type isn't "album", but that all depends on what you really want. |
|
tempg
Joined: 2005-12-17
Posts: 1857 |
![]() |
inebriated wrote:
i dont like the idea of including the user/pass in the file itself Ditto that. spags wrote:
where type="photo" Yep. |
|