php


How can i count images per album in php [closed]


How can i count upload images per album based on user id..i have done this but is not ok..some help is appreciated. I'm new learner!
Here is what i have:
Album db: |albumid|name|image|uid| <- user id
Gallery db: |galleryid|albumid|name|images|uid|
Code
$sql = "
SELECT COUNT(userid)
FROM tbl_gallery
where userid = 1
";
$rs_result = mysql_query($sql,$con);
$row = mysql_fetch_row($rs_result);
$total_records = $row[0];
echo $total_records;
$sql = "SELECT * FROM tbl_album where userid = 1 ORDER BY albumid";
$rs_result = mysql_query($sql,$con);
####### Fetch Results From Table ########
while ($row = mysql_fetch_assoc($rs_result))
{
$aimage=$row['image'];
$aid=$row['albumid'];
$aname=$row['name'];
<div class="pic">
<?php
echo "<a href='includes/galeriefoto/gallery.php?id=1'> <img src='includes/galeriefoto/admin/acatch/$aimage' class='thumbimg' alt='Pic' alt='$aname'>";
?>
<span class='pic-caption'>
<center><p style='color:#000;font-size:24px'><?php echo $aname;?> (<?php echo $total_records;?>)</p></center>
</span></a>
</div>
<?php } ?>
If it is just about counting the number of images in an album, the following would suffice for your query:
SELECT uid, albumid, COUNT(galleryid) as num_upload_images
FROM tbl_gallery
GROUP BY uid, albumid
This results in the following possible output:
[0] => [
uid => 1,
albumid => 1,
num_upload_images => 15
],
[1] => [
uid => 1,
albumid => 2,
num_upload_images => 12
]

Related Links

How can I remove the ascii character x02 from my string with php?
PHP : Retrieving keys using openssl
PHP, Zend/x Debugger
How to add reply to youtube's video comment using API with PHP
Symfony2: How to handle dynamic “nav” bar
Vanity URLS & Xampp
PHP Hex String Send as Socket
In PHP, what does echo followed by two single quotes mean?
getting javascript error object required
How to take first file name from a folder and delete it in PHP
PHP script not updating mysql table
PHP ternary conditional. Yes or no and why?
Using preg_replace and preserving part of search
jQuery function not working with some browsers
PHP array creation with information displayed in a dropdown
Uploading a photo from Android with Phonegap

Categories

HOME
google-chrome
class
yaml
clearcase
dotnetnuke
paypal-ipn
add-on
loopbackjs
plaid
informatica
yql
firebase-dynamic-links
firebase-database
u-boot
jpa-criteria
azure-logic-apps
lapack
alljoyn
graphdb
smooks
xbap
stimulsoft
amazon-elb
trace32
l20n
jqxgrid
gravity
exec-maven-plugin
adminlte
android-custom-view
angular2-highcharts
pe
sharedpreferences
intel
eclipse-emf
prompt
morris.js
webviewclient
bonita
docx4j
instructions
mongodb-3.4
cloudera-manager
counting
cmis
gitolite
moinmoin
brightscript
password-hash
sharpdx
openstack-glance
sigsegv
embedded-v8
http-basic-authentication
predicates
annotatorjs
ipywidgets
java-2d
clp
nvda
gcloud-node
mathml
coovachilli
fragmentstatepageradapter
gravatar
voronoi
odesk
largenumber
nssortdescriptor
rfc5545
mathematical-expressions
android-audiomanager
vs-unit-testing-framework
rubber
multivariate-testing
visual-c++-2012
aho-corasick
siena
commenting
cpu-time
lync-2010
vlab
lru
examine
contextswitchdeadlock
simplecov
xcode4.5
thejit
kolite
infopath-2007
uipasteboard
azure-acs
printqueue
android-2.1-eclair
jdownloader
ninject-interception
cleartype
rational-unified-process
remote-working

Resources

Encrypt Message