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