steviez Posted April 4, 2007 Share Posted April 4, 2007 Hi, I run a upload site and need some help with the coding.. What i am trying to do is show how much disk space a user has used, all the users details and uploads are stored in a database and all upload go in to one file called "files" Is this possable using php? Thanks Link to comment https://forums.phpfreaks.com/topic/45606-solved-help-with-code/ Share on other sites More sharing options...
obsidian Posted April 4, 2007 Share Posted April 4, 2007 Are you storing the individual file attributes (filesize, name, path, etc) in the database? That would be the wisest and easiest way to go. With that, you could simply query your database for the SUM() of all their filesizes, and you would be able to know exactly what had been used and is available. Link to comment https://forums.phpfreaks.com/topic/45606-solved-help-with-code/#findComment-221488 Share on other sites More sharing options...
steviez Posted April 4, 2007 Author Share Posted April 4, 2007 Yes i am, i am new to php.. could you help me with this Link to comment https://forums.phpfreaks.com/topic/45606-solved-help-with-code/#findComment-221491 Share on other sites More sharing options...
obsidian Posted April 4, 2007 Share Posted April 4, 2007 If you have the filesize stored in the table along with who it belongs to, you can run a SUM() query to get the total filesize of all their files. Somthing like this may be what you're after: <?php $sql = mysql_query("SELECT SUM(filesize) AS total, userID FROM myFileTable GROUP BY userID"); ?> That query will give you the total filesize of all users tied to their userID. Of course, you'll have to provide your own table names and column names, but the principle is there. Link to comment https://forums.phpfreaks.com/topic/45606-solved-help-with-code/#findComment-221526 Share on other sites More sharing options...
steviez Posted April 4, 2007 Author Share Posted April 4, 2007 Hi, Thanks for that it workd great, this might be a silly question but. how do i echo the result? Link to comment https://forums.phpfreaks.com/topic/45606-solved-help-with-code/#findComment-221562 Share on other sites More sharing options...
razta Posted April 4, 2007 Share Posted April 4, 2007 $result = mysql_query ($sql); echo $result; That should work. Link to comment https://forums.phpfreaks.com/topic/45606-solved-help-with-code/#findComment-221583 Share on other sites More sharing options...
steviez Posted April 4, 2007 Author Share Posted April 4, 2007 nope it dont work, my sit euses adodb for the sql Link to comment https://forums.phpfreaks.com/topic/45606-solved-help-with-code/#findComment-221584 Share on other sites More sharing options...
steviez Posted April 4, 2007 Author Share Posted April 4, 2007 sorted it out, thanks for all your help guys! Link to comment https://forums.phpfreaks.com/topic/45606-solved-help-with-code/#findComment-221594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.