logo
down
shadow

How to view first image in list per user as its highlight Profile


How to view first image in list per user as its highlight Profile

Content Index :

How to view first image in list per user as its highlight Profile
Tag : php , By : Jesse
Date : November 24 2020, 03:01 PM

Hope that helps you are looping on all results of your query, so of course you will get all images. Your query is to generic.
Now I assume your table is something like this:
SELECT file_name
FROM member_images
WHERE uid = <SOME UID>
ORDER BY upload_time DESC
LIMIT 1
SELECT *
FROM member_images AS m
INNER JOIN (SELECT uid, max(upload_time) as latest
            FROM member_images
            GROUP BY uid) AS r
            ON m.upload_time = r.latest and m.uid = r.uid
ORDER BY upload_time DESC

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Tag : drupal , By : user130518
Date : March 29 2020, 07:55 AM
it should still fix some issue i thing you are created the view with the base type user. please change the type to node. So you can access all the content_profile field from the views.

How to display different session status' on a profile page (guest view vs. user profile view)


Tag : php , By : meodudang
Date : March 29 2020, 07:55 AM
hop of those help? There are a few things that would help you. I have notated for clarity:
<?php
// Add connection here...(should be a PDO or mysqli_)
session_start();
// Add a simple true/false function to test for logged in
// Would be better included on this page rather than written (like connection)
function is_loggedin()
    {
        return (!empty($_SESSION['user_login']));
    }
// Make a function to test if the logged-in user is currently viewing own profile
// Would be better included on this page rather than written (like connection)
function is_profile($user = false)
    {
        if(!$user)
            return false;

        return (is_loggedin() && ($_SESSION['user_login'] == $user));
    }
// Presumably you would have profile.php?u=23432 or similar 
// If no user requested just assign false
$user   =   (!empty($_GET['u']) && ctype_alnum($_GET['u']))? $_GET['u'] : false;
// If the user is valid (not empty)
// Would be better included on this page if condition is met otherwise
// It just kind of loads extra lines for nothing
if($user != false) {
        // You should not be using mysql_ anymore, PDO or mysqli_ with prepared/bound statements
        $username   =   mysql_real_escape_string($user);
        //check user exists
        $check      =   mysql_query("SELECT username, first_name FROM users WHERE username='$username'");

        if (mysql_num_rows($check) === 1) {
                $get        =   mysql_fetch_assoc($check);
                $username   =   $get['username'];
                $firstname  =   $get['first_name'];  
            }
        else {
                echo "<meta http-equiv=\"refresh\" content=\"0; url=http://localhost/tutorials/index.php\">"; 
                exit;
            }
    }
// Just do one wrapper
$optionbox[]    =   '<div style="border:#CCC 1px solid; padding:5px; background-color:#E4E4E4; color:#999; font-size:11px;">';
// Check if a user is logged in
if(is_loggedin())
    // If the logged in user matches the $_GET user
    $optionbox[]    = (!is_profile($user))? '<a href="#">Add friend</a>' : '<a href="#">friend list</a>';
// If user is not logged in
else
    $optionbox[]    =   '<h3>You must be logged in to view stuff and things</h3>';
// Finish wrapper
$optionbox[]    =   '</div>';
// Write to page
echo implode(PHP_EOL,$optionbox);
?>
<?php
// Have a general driver interface incase you need different database
// connection interfaces (MSSQL, etc)
interface DBDriver
    {
        public  static  function connect($user,$pass,$host,$dbname);
    }
<?php
// Create MySQL PDO Connection based on the DBDriver preferences
class Database implements DBDriver
    {
        // This will store our connection for reuse
        private     static  $singleton;
        // This will store the connection options
        protected   static  $dbOpts;
        // This is the actual connecting to database
        public static   function connect($user,$pass,$host,$dbname)
            {
                if(isset(self::$singleton))
                    return self::$singleton;

                if(!isset(self::$dbOpts))
                    self::SetDatabaseAttr();

                try {
                        self::$singleton = new PDO("mysql:host=$host;dbname=$dbname",$user,$pass, self::$dbOpts);
                        self::$singleton->exec('SET NAMES "utf8"');
                    }
                catch(PDOException $e){
                        echo "unable to connect to server";
                        exit;
                    }

                return self::$singleton;
            }
        // This sets the options for your database.
        public  static  function SetDatabaseAttr($value = false,$refresh = false)
            {
                if(!is_array($value) || empty($value)) {                        
                        self::$dbOpts[PDO::ATTR_ERRMODE]            =   PDO::ERRMODE_EXCEPTION;
                        self::$dbOpts[PDO::ATTR_DEFAULT_FETCH_MODE] =   PDO::FETCH_ASSOC;
                        self::$dbOpts[PDO::ATTR_EMULATE_PREPARES]   =   false;
                    }
                else {
                        if(empty(self::$dbOpts) || $refresh)
                            self::$dbOpts   =   array();

                        foreach($value as $DBKey => $DBValue)
                            self::$dbOpts[$DBKey]   =   $DBValue;
                    }

                return self::$dbOpts;
            }
    }
<?php
// This class can be expanded out to do a lot more than just fetch from the database
class QueryEngine
    {
        protected   $query;
        private static  $singleton;
        // Create and Return instance of itself
        public  function __construct()
            {
                if(!empty(self::$singleton))
                    self::$singleton    =   $this;

                return self::$singleton;
            }
        // Basic query method
        public  function query($sql = false, $bind = false)
            {
                AutoloadFunction("PDOConnect");
                $con            =   PDOConnect();
                $this->query    =   $con->prepare($sql);

                if(!empty($bind)) {
                        foreach($bind as $key => $val) {
                                $bindVals[":{$key}"]    =   $val;
                            }

                        $this->query->execute($bindVals);
                    }
                else
                    $this->query->execute();

                return $this;
            }
        // This function is what returns the array in conjunction with
        // the query method
        public  function Fetch()
            {
                if($this->query) {
                        while($row = $this->query->fetch(PDO::FETCH_ASSOC)) {
                                $result[]   =   $row;
                            }
                    }

                return (!empty($result))? $result : 0;
            }   
    }
<?php
// This function is what is used to autoload classes on the fly
// There is no need to include class files, so long as they are in the
// /classes/ folder
function AutoLoadClasses($className) {
        if(class_exists($className)) {
                return;
            }

        if(is_file(CLASSES_DIR."/class.".$className.'.php')) {
                include_once(CLASSES_DIR."/class.".$className.'.php');
            }
    }
<?php
// This will attempt to load the required file to run a specified function
// Similar to the autoloader for the classes, only this is required to be
// manually called like: AutoloadFunction("myfunction"); before function use
function AutoloadFunction($function = false,$loaddir = false)
    {
        if($function == false)
            return false;

        if(strpos($function,","))
            $functions  =   explode(",",$function);

        $function_dir   =   ($loaddir != false && !is_array($loaddir))? $loaddir.'/function.': FUNCTIONS_DIR.'/function.';

        if(!isset($functions)) {
                $functions[]    =   $function;
            }

        for($i = 0; $i < count($functions); $i++) {
                // Function name
                $addfunction    =   $functions[$i];
                // See if function exists
                if(!function_exists($addfunction)) {

                        $dir    =   $function_dir.$addfunction.'.php';
                        if(is_file($dir)) {
                                include_once($dir);
                            }
                    }
            }
    }
<?php
// Just make a quick PDO function to return your PDO Connection
// populate the arguements with your database credentials
function PDOConnect($user = "username",$pass = "password",$host = "hostname",$data = "databasename")
    {
        return Database::connect($user,$pass,$host,$data);
    }
<?php
// Here is a quick array fetching function using the query engine class
function query_fetch($sql = false,$bind = false)
    {
        $qEngine    =   new QueryEngine();
        return $qEngine ->query($sql,$bind)
                        ->Fetch();
    }
<?php
// Add a simple true/false function to test for logged in
function is_loggedin()
    {
        return (!empty($_SESSION['username']));
    }
<?php
// Make a function to test if the logged-in user is currently viewing own profile
function is_profile($user = false)
    {
        if(!$user)
            return false;
        AutoloadFunction("is_loggedin");
        return (is_loggedin() && ($_SESSION['username'] == $user));
    }
<?php
// This will fetch the user based on a get variable
function get_profile($username = false)
    {
        // Presumably you would have profile.php?u=23432 or similar 
        // If no user requested just assign false
        $user                   =   (!empty($_GET['u']) && ctype_alnum($_GET['u']))? $_GET['u'] : false;
        $array['username']      =   false;
        $array['first_name']    =   false;
        // If the user is valid (not empty)
        // Would be better included on this page if condition is met otherwise
        // It just kind of loads extra lines for nothing
        if($user != false) {
                AutoloadFunction("query_fetch");
                //check user exists
                $get      =   query_fetch("SELECT `username`, `first_name`,`ID` FROM `users` WHERE `username` = :0",array($user));

                if ($get != 0) {
                        $array['username']      =   $get[0]['username'];
                        $array['ID']            =   $get[0]['ID'];
                        $array['first_name']    =   $get[0]['first_name'];

                        return ($username)? $array['username'] : $array; 
                    }
                else {
                        header("location: http://localhost/tutorials/index.php"); 
                        exit;
                    }
            }

        return $array;
    }
<?php
// Define some basic locational constants
define("ROOT_DIR",__DIR__);
define("CLASSES_DIR",ROOT_DIR."/classes");
define("FUNCTIONS_DIR",ROOT_DIR."/functions");
// Load up the functions autoloader
include_once(FUNCTIONS_DIR."/function.AutoloadFunction.php");
// Load up the function for class autoloading
AutoloadFunction("AutoLoadClasses");
// Apply the autoloader for classes
spl_autoload_register('AutoLoadClasses');
<?php
session_start();
// Load all the settings to make things work.
include(__DIR__."/config.php");
?>
<div style="border:#CCC 1px solid; padding:5px; background-color:#E4E4E4; color:#999; font-size:11px;">
<?php
// Using the "AutoloadFunction" should save execution time because
// it will only load functions it needs instead of loading all the functions 
// it could "potentially" need.
AutoloadFunction("is_loggedin");
// Check if a user is logged in
if(is_loggedin()) {
        AutoloadFunction("get_profile,is_profile");
        // Fetch the profile of current user query
        $user           =   get_profile();
        // If the logged in user matches the $_GET user
        echo (!is_profile($user['username']))? '<a href="?action=add&u='.$user['ID'].'">Add '.ucwords($user['first_name']).'</a>' : '<a href="#">friend list</a>';
    }
// If user is not logged in
else {
?>
    <h3>You must be logged in to view stuff and things</h3>
<?php }
?>
</div>

show a Facebook user profile image from url to image view


Tag : ios , By : appdelivery
Date : March 29 2020, 07:55 AM
should help you out I have a url of image which is fetched by the Facebook profile .I fetch those url and copy in to string "urlpicture" .In url picture my url show but when i pass in "geturl"which is a string type property in another file .when i go in to another file "geturl " is nil. , try this, actually pass the variable before navigation
HomeViewController *pushWithSlot=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

 pushWithSlot.geturl=_urlpicture;
[self.navigationController setViewControllers:@[pushWithSlot] animated:YES];
{    NSDictionary *pictureData  = [result valueForKey:@"picture"];
                    NSDictionary *redata = [pictureData valueForKey:@"data"];
                            _urlpicture = [redata valueForKey:@"url"];

       // call after URL Fetch
                 HomeViewController *pushWithSlot=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

 pushWithSlot.geturl=_urlpicture;
[self.navigationController setViewControllers:@[pushWithSlot] animated:YES];
                }
  {    NSDictionary *pictureData  = [result valueForKey:@"picture"];
                    NSDictionary *redata = [pictureData valueForKey:@"data"];
                            _urlpicture = [redata valueForKey:@"url"];

       // call after URL Fetch
                 HomeViewController *pushWithSlot=[self.storyboard instantiateViewControllerWithIdentifier:@"HomeViewController"];

 pushWithSlot.geturl=pushWithSlot;
[self presentViewController:pushWithSlot 
               animated:YES 
             completion:nil];
                }

how to create view like image attached . Last seen user profile image show in this


Tag : swift , By : Brian
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Create UIImageView's with same width and height. then set the corner radius = width/2 Set the layer border color to white and set layer border width to some value that suits the white border. Above two points will give you circular imageViews. Make as many as you need Take a parent UIView . Add the UIImageView's as subviews on that parent view from left to right with enough padding that suits your need. this will create the overlapping effect of the profile icons - like the ones in the image

Should I use a list view or View to create the lines below the user's information as shown in this image?


Tag : android , By : AdrianB
Date : March 29 2020, 07:55 AM
This might help you A ListView would make your code more maintainable, but if it's just static elements on the screen and you're sure you're not going to add anything, you could definitely use a simple View. i use LinearLayouts for underlines like those.
 <LinearLayout
        android:id="@+id/divider1"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_below="@+id/title1"
        android:layout_marginTop="5dp"
        android:background="#52525252"
        android:orientation="horizontal"></LinearLayout>
Related Posts Related QUESTIONS :
  • Laravel - Ordering a collection of models
  • PHP Fatal error: Uncaught Error: Call to a member function setFetchMode() on boolean
  • Strict Standards: Only variables should be passed by reference in /main_dir/sub_dir/backup.php
  • Uncaught Google_Exception: (update) unknown parameter: 'copyRequiresWriterPermission'
  • Laravel 5 form does not redirect with old input
  • How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?
  • PHP datediff overday issue
  • Masking an auto incrementing primary key
  • How to grab a String BEFORE a certain word
  • ZF2 Routing Multiple Controllers based on route constraints
  • How to deregister/dequeue jquery.sticky.js in Elementor (Pro)?
  • How to fix errors counting words in text plain with PHP?
  • How to get View data in Laravel in custom helper or directive
  • Creating a new data entry into a database with eloquent and trying to access the variable in the url
  • How to test authentication using Laravel Dusk?
  • PHP parse_str not getting all $_GET variables
  • Variable issues in php class
  • Get orders between dates in Codeigniter
  • Eloquent Special Chars Issue
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • Outlook Marking Email as Junk Email
  • Upload an image using class.upload.php via AJAX, display image in form using jQuery
  • mysql_connect() causes page to not display (WAMP)
  • How to limit a users uploaded image size using PHP
  • What's the difference whether or not to run PHP in safe mode?
  • Logging in to a website cURL
  • Using php to create a password system with chinese characters
  • PHP is not called properly in IE using set interval function in Javascript
  • How to read pdf, ppt, xl, doc files content into a string in php/python
  • php script for currency conversion
  • In PHP... best way to turn string representation of a folder structure into nested array
  • PayPal for Indian Rupees (INR) any solution
  • PHP Deployment to Live Server
  • Ideal Multi-Developer Lamp Stack?
  • How can I save an image from a file input field using PHP & MySQL?
  • Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag in
  • Connecting to external MySQL DB from a web server not running MySQL
  • Is it possible to add custom fields to a Drupal taxonomy term?
  • PHP 6.0 - Roadmap?
  • jQuery wait for ajax call to be over before continuing
  • checkUnique function?
  • How to define an n-m relation in doctrine?
  • Sort the unsorted text file and rewrite to same text file in sorted order
  • Version control a content management system?
  • How can i run Single PHP File using apache-tomcat-6.0.18?
  • Array of objects is empty when I come to retrieve one from the array
  • PHP Library: Calculate a bounding box for a given lat/lng location
  • Good Wordpress Theme/plugin for showing off code examples and scripts
  • Replace all spaces and special symbols with dash in URL using PHP language
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com