Current location: Hot Scripts Forums » Programming Languages » PHP » Display info for all users


Display info for all users

Reply
  #1 (permalink)  
Old 02-16-08, 02:35 AM
caedas caedas is offline
New Member
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Display info for all users

Hi all, long time visitor, first time poster!

I am new to PHP and have been stuck for a LONG time on the following problem:

I am trying to edit a program which someone else made which gets the current user id and displays correct values for that user id...however, I want it to display all usernames and values.

Here is what I have so far (from the modified code). I made a few aesthetic changes to make it easier to read, which would result in minor errors, but the code is the same I only changes the values for the $userResult variable. The rest get info for the current user_id.:

PHP Code:

<?php

$relative_root 
"../";
require (
"../util/wrapper.php");


//Commented out for testing purposes
/*global $_GET;
$user_id = $_GET["user"];
$can_access = false;
if ($user_id == $GLOBALS["session_user_id"] || $GLOBALS["session_is_admin"] == true)
$can_access = true;
if (!$can_access)
        httpRedirect($relativeRoot);
*/

//Gets all the needed info for the current user...


    
$userResult dbQuery("SELECT * FROM user");
        echo 
mysql_error();
            
$userRow mysql_fetch_assoc($userResult);
        
    
$totalResult dbQuery("SELECT SUM(points) AS total FROM points WHERE user_id=" $user_id "GROUP BY user_id");
        echo 
mysql_error();
            
$totalRow mysql_fetch_assoc($totalResult);

    
$totalDie dbQuery("SELECT SUM(points) AS total FROM points WHERE user_id=" $user_id "AND custom_event_id=1 
        GROUP BY user_id"
);
        echo 
mysql_error();
            
$totalE1 mysql_fetch_assoc($totalDie);

    
$totalNim dbQuery("SELECT SUM(points) AS total FROM points WHERE user_id=" $user_id "AND custom_event_id=2 
        GROUP BY user_id"
);
        echo 
mysql_error();
            
$totalE2 mysql_fetch_assoc($totalNim);

    
$totalTul dbQuery("SELECT SUM(points) AS total FROM points WHERE user_id=" $user_id "AND custom_event_id=3 
        GROUP BY user_id"
);
        echo 
mysql_error();
            
$totalEv3 mysql_fetch_assoc($totalTul);

    
$totalLum dbQuery("SELECT SUM(points) AS total FROM points WHERE user_id=" $user_id "AND custom_event_id=4    
        GROUP BY user_id"
);
        echo 
mysql_error();
            
$totalEv4 mysql_fetch_assoc($totalLum);

    
$totalBak dbQuery("SELECT SUM(points) AS total FROM points WHERE user_id=" $user_id "AND custom_event_id=5 
        GROUP BY user_id"
);
        echo 
mysql_error();
            
$totalEv5 mysql_fetch_assoc($totalBak);


$body "

    <p align=\"center\"><font size=\"+2\"><b>Program Name</b></font>:</p>

    <BR>

    "
;

$body .= "

    <table border=1 cellpadding=2 align=center>

        <tr>

            <td><b>User</b></td>
            
            <td><b>Total</b></td>

            <td><b>Event 1</b></td>

            <td><b>Event 2</b></td>

            <td><b>Event 3</b></td>

            <td><b>Event 4</b></td>
        
            <td><b>Event 5</b></td>

        </tr>
    "
;


//This is my own doing:

while ($u_row mysql_fetch_assoc($userResult))
{
                
$body .= "<tr>";
                
$body .= "<td>" $u_row["char_name"] . "</td>";
}
                
$totalResult dbQuery("SELECT SUM(points) AS total FROM points WHERE user_id=" $u_row["user_id"] . "GROUP BY user_id");
                
$body .= "<tr>";
                
$body .= "<td>" $totalResult["total"] . "</td>";
                
$body .= "</tr>";

                
/* Commented out because I am not sure where they go...    
                                * but these are the values I need from each user:
  
                * $body .= "<td>" . $totalResult["total"] . "</td>";
                * $body .= "<td>" . $totalEv1["total"] . "</td>";
                    * $body .= "<td>" . $totalEv2["total"] . "</td>";
                * $body .= "<td>" . $totalEv3["total"] . "</td>";
                * $body .= "<td>" . $totalEv4["total"] . "</td>";
                * $body .= "<td>" . $totalEv5["total"] . "</td>";
                */

        
$body .= "</tr>";
        
$body .= "
    </table>

"
;



echo 
makePage($body);
    
dbClose();


?>

Alot of things in there are included functions as I am sure you could have guesses.

Again what I want is a table that displays all user names, total amount, event 1 amount, event 2 amount (...) event 5 amount...so 7 columns that need filling in; 1 of which I have done.

I changed some of the names because it isn't my code, but if you would like to help me 1 on 1, or need me to post more here, I will...just ask!

Thanks in advance for the help!
Reply With Quote
  #2 (permalink)  
Old 03-04-08, 07:52 AM
Dale Dale is offline
Newbie Coder
 
Join Date: Dec 2003
Location: London, UK
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Well looking at the script, whatever the column in the database is called, for instance "username", if the column is called username then you will have to wrap it with ->
PHP Code:

$u_row[""
. For example (column "dale") ->
PHP Code:

$u_row["dale"
Get it?
__________________
>>> DaleHay.com <<<
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse Over Text to display MySql Info lylesback2 PHP 9 01-18-08 04:26 PM
gather user info and display jmyers1643 Script Requests 1 06-25-07 12:49 PM
how to display info from a text box in a text area? Ademuth PHP 7 08-31-05 12:58 PM
Using Flash to display users online... musiq The Lounge 2 08-15-04 01:59 AM


All times are GMT -5. The time now is 07:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.