Jump to content

Recommended Posts

Hey,

 

I have been doing a lot of research and just cannot find the answer, I got php to generate a table from MySQL stats, now it gets all the information from the database for the specific logged in user and will display it, under the table I want to put the totals of the numbers.

 

If you can't understand what I have just said, this is an example: http://img145.imageshack.us/img145/2386/tabletotalvs4.jpg

 

It basically needs to calculate the users rows if I have said it clearly or something on the lines of that, I guess I'm a newbie to this ???

This was my full code:

 

<?php

$user1 = $_SESSION['username'];

$user_sql = mysql_query("SELECT * FROM `users` WHERE `username` = '$user1'");

$userinfo = mysql_fetch_array($user_sql);

$username =  $userinfo['username'];



$sql1 = mysql_query("SELECT * FROM `logs` WHERE `username` = '$username'") or die("Cannot select History at this time");



$sql1_rows = mysql_num_rows($sql1);







if($sql1_rows == "0") {



echo 'You have never done anything.';



} else {



echo '<table border="0" align="center" width="60%">



<tr>




<th>Date</th>



    <th>File Name</th>



    <th>FileSize (KB)</th>



<th>IP</th>







</tr>';



while($history = mysql_fetch_array($sql1)) {



echo '<tr>



    <td align="center">'.$history['fdate'].'</th>



<td align="center">'.$history['filename'].'</th>



    <td align="center">'.$history['filesize'].'</th>

    <td align="center">'.$history['ip'].'</th>






</tr>';



}



echo '</table>';



}



?>
    </p>
    <p align="center">Total:</p>
    <p align="center">
        
       <?php

$query = mysql_query("SELECT * FROM `logs` WHERE `username` = '$user1'"); 
$rows  = mysql_num_rows($query)

echo $rows['filesize'];

?>

try

<?php
$user1 = $_SESSION['username'];
$user_sql = mysql_query("SELECT * FROM `users` WHERE `username` = '$user1'");
$userinfo = mysql_fetch_array($user_sql);
$username =  $userinfo['username'];
$sql1 = mysql_query("SELECT * FROM `logs` WHERE `username` = '$username'") or die("Cannot select History at this time");
$sql1_rows = mysql_num_rows($sql1);
if($sql1_rows == "0") {
echo 'You have never done anything.';
} else {
$total = 0;
echo '<table border="0" align="center" width="60%">
<tr>
  <th>Date</th>
    <th>File Name</th>
    <th>FileSize (KB)</th>
   <th>IP</th>
</tr>';
while($history = mysql_fetch_array($sql1)) {
$total += $history['filesize'];
echo '<tr>
    <td align="center">'.$history['fdate'].'</th>
   <td align="center">'.$history['filename'].'</th>
    <td align="center">'.$history['filesize'].'</th>
    <td align="center">'.$history['ip'].'</th>
</tr>';
}
echo '</table>';
}
?>
     </p>
     <p align="center">Total:</p>
     <p align="center">
<?php
//$query = mysql_query("SELECT * FROM `logs` WHERE `username` = '$user1'");
//$rows  = mysql_num_rows($query);
echo $total;
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.