Jump to content

I need the avatar to show along with the username


KDM

Recommended Posts

Can you guys help me modify this code? I have a row in my database that is called avatar.

 

 

This is at the top of my page

 

<?php
if (isset($_GET['logout']) && ($_GET['logout'] == '1')) {
session_destroy();
$msg = '<span style="color:#ffffff;">you are now logged out.</span>';
}
require_once('admin_common.php');
session_start();

/**
* This is function _get_top_uploader
*
* @return mixed Associative array where ['user_id'] and ['freq'].
*
*/
function _get_top_uploader() {
  global $ezdb;
  $_start = (int)(time() / 86400) * 86400 - 25200;
  $_info = $ezdb->get_results(
    "SELECT user_id, count(*) AS freq " .
    "FROM image_map " .
    "WHERE obj_type = 'image' " .
    "AND date_added >= $_start " .
    "GROUP BY user_id " .
    "ORDER BY freq DESC", 
    'ARRAY_A');
  if ($_info != null) { 
    $_info[0]['user'] = $_info[0]['user_id'];
    $_info2 = $ezdb->get_results(
      "SELECT username " .
      "FROM users " .
      "WHERE user_id = {$_info[0]['user_id']} ",
      'ARRAY_A');
    if ($_info2 != null) {
      $_info[0]['user'] = $_info2[0]['username'];
    }
    else {
      $_info[0]['user'] = $_info[0]['user_id'];
    }
    return $_info[0];
  }
  else {
    return null;
  }
}

 

 

 

This is where the user with the most uploads is printed out.

  	<div id="mostuploads">';
      $_info = _get_top_uploader();
      if ($_info != null) {
        $foot .= "<div style='padding-top:30px;'>Most valuable user today is {$_info['user']} with {$_info['freq']} photo uploads!</div>";
      }
    			   $foot .= '</div>

</div>

</div>'.$clear;

Link to comment
Share on other sites

It's not your code. I don't like coding for you.

 

If you have a basic understanding of PHP/HTML, you should be able to follow what this script is doing. Displaying another field from an existing query is trivial, assuming you understand what's going on.

 

I suggest paying someone $20-$40 to do this for you. It's cheap, and ideally it'll be done by a professional who won't open up holes.

Link to comment
Share on other sites

Which means putting it in the freelance section,

 

12. All request for code to be written for you should be posted under the freelance section. No exceptions.

 

however.. if your willing to learn then maybe this will point you in the right direction

 

 

change

SELECT user_id, count(*) AS freq 

to

SELECT user_id, count(*) AS freq, avatar 

 

$_info[0]['user'] = $_info2[0]['username'];
$_info[0]['avatar'] = $_info2[0]['avatar']; //Add

 

update

with {$_info['freq']} 

to something like

with {$_info['freq']} <img src="{$_info['avatar']}" /> 

 

Hope that helps!

Link to comment
Share on other sites

It's not your code. I don't like coding for you.

 

If you have a basic understanding of PHP/HTML, you should be able to follow what this script is doing. Displaying another field from an existing query is trivial, assuming you understand what's going on.

 

I suggest paying someone $20-$40 to do this for you. It's cheap, and ideally it'll be done by a professional who won't open up holes.

 

I already paid someone to do work on this script. I'm trying to learn, not continue to pay people duh.

Link to comment
Share on other sites

Which means putting it in the freelance section,

 

12. All request for code to be written for you should be posted under the freelance section. No exceptions.

 

however.. if your willing to learn then maybe this will point you in the right direction

 

 

change

SELECT user_id, count(*) AS freq 

to

SELECT user_id, count(*) AS freq, avatar 

 

$_info[0]['user'] = $_info2[0]['username'];
$_info[0]['avatar'] = $_info2[0]['avatar']; //Add

 

update

with {$_info['freq']} 

to something like

with {$_info['freq']} <img src="{$_info['avatar']}" /> 

 

Hope that helps!

 

Thanks I'll give that a try. I just need a push in the right direction.

Link to comment
Share on other sites

I already paid someone to do work on this script. I'm trying to learn, not continue to pay people duh.

 

This is a terrible way to learn, IMO.

 

Start small, work your way up.

 

I'd be more willing to help you if you showed some effort in trying to do it yourself, rather than 'TEACH ME PHP PLEASE'

Link to comment
Share on other sites

Or even code you thought you understood - register_globals turns off in 4.2 and I was like WHAT THE HELL ARE YOU GUYS DOING?! 5 minutes of reading and I had much less of an issue rewriting my scripts.

Link to comment
Share on other sites

You can almost copy and paste MadTechie's solution directly in to your script - and you're unhappy?!

 

This is why I didn't 'help' you in the first place.

 

I won't miss you.

 

it didn't work...obviously.

Link to comment
Share on other sites

The code he provided is the correct way to implement it in to whoever's script.

 

You being unable to just shows you shouldn't be touching the code. Who knows if a solution someone gives you won't open up security holes?

Link to comment
Share on other sites

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.