Jump to content

Member List Picture Display


Accurax

Recommended Posts

I have a member list that displays all my members names, and allows your to view each members profile by clicking on the generated links.

I'd like to take this a ittle further now and also display each members picture next to their name, however i cant seem to get my head arround it.

Can anyone help?

Heres what I have at the moment

[code]
<?php
session_start();
include("include.inc");
if ( $_SESSION['login'] != "true" )
{
header("location: hacker.php");
}
else
{
echo "<h1 align='center'>Here is our Member List<br /></h1>";
}

$connection=mysql_connect($host, $user, $passwd)
or die ("Could not connect !");
$db = mysql_select_db($database, $connection)
or die ("Could not connect to Database");


$user_query = "SELECT user_name FROM members";
$result = mysql_query($user_query)
or die ("cant get links");
$row = mysql_fetch_array($result);
$profilename = $row[user_name];

$user_picture = "SELECT picture FROM members WHERE user_name='$profilename'$";
$result = mysql_query($user_picture)
or die ("cant get pictures");
$row = mysql_fetch_array($result);
$picture = $row[picture];

echo '<a href="view_profile.php?user_name='.$row['user_name'].'">'; echo $row['user_name']; echo "</a>";
echo "<br>";
echo '<img src="$picture" width="200" height="40" title="Logo" />';
$profile = $row['user_name'];

while ( $row = mysql_fetch_array($result))
{
echo '<a href="view_profile.php?user_name='.$row['user_name'].'">'; echo $row['user_name']; echo "</a>";
echo "<br>";
}
?>[/code]

By the way, at the moment its defaulting to the "or die" statement for the SELECT picture query.
Link to comment
Share on other sites

This is assuming that you have 2 different databases, which I have.
This works for me

You can see what I mean here
[url=http://fotobins.com/test.php]http://fotobins.com/test.php[/url]

[code]
$user_query = "SELECT username FROM users";
$result = mysql_query($user_query)
or die ("cant get links");
$row = mysql_fetch_array($result);
$profilename = $row[username];

$photo_query = "SELECT * FROM photos WHERE username = '$row[username]'";
$result1 = mysql_query($photo_query)
or die ("cant get photos");
$row = mysql_fetch_array($result1);
$photoname = $row[file];
echo "$row[username] - $row[file]";
[/code]
Link to comment
Share on other sites

Im using one database in all honesty

But... i have managed to get it working thanks to an old thread i dug up from last year sometime lol.

I'm starting to do some formatting on it now, and will probably have some questions sometime tomorrow on multiple page displays etc... ill have a go myself first though

Thanks guys
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.