Jump to content

[SOLVED] showing friends images in two colums


runnerjp

Recommended Posts

here is my script

 

<? include'../../settings.php';

$sql="SELECT friends.friendname, users.image FROM friends INNER JOIN users ON (users.friendname=friends.friendname) WHERE friends.username='Admin' GROUP BY friends.friendname ORDER BY users.friendname ";

// Showing
$res = mysql_query($sql) or die(mysql_error());
echo '<table><tr><th>Name</th><th>Picture</th></tr>'; 

while($row = mysql_fetch_assoc($res)){
  echo "<tr><td>" . $row['friendname'] . "</td><td><td>". $row['image"] ."</td></tr>";
}
echo "</table>"; 

?> 

 

but i would like to change it as users only have 1 profile picture and i would like to have it like this

 

Untitled.jpg

Link to comment
Share on other sites

try this

$sql="SELECT friends.friendname, users.image FROM friends INNER JOIN users ON (users.friendname=friends.friendname) WHERE friends.username='Admin' GROUP BY friends.friendname ORDER BY users.friendname ";

// Showing
$res = mysql_query($sql) or die(mysql_error());
define('NUMCOLS', 3);	
	$count = 0;
	$counter = 1;
echo '<table><tr><th>Name</th><th>Picture</th></tr>'; 

while($row = mysql_fetch_assoc($res)){
	if($count % NUMCOLS == 0)
	echo '<tr>';
	echo '<td>';
   		echo "<tr><td>" . $row['friendname'] . "</td><td><td>". $row['image'] ."</td></tr>";

	$count++;
	$counter++;
	if($count % NUMCOLS == 0)
	echo '</tr>'; //end row
}
echo "</table>"; 

Link to comment
Share on other sites

$sql="SELECT friends.friendname, users.image FROM friends INNER JOIN users ON (users.friendname=friends.friendname) WHERE friends.username='Admin' GROUP BY friends.friendname ORDER BY users.friendname ";

// Showing
$res = mysql_query($sql) or die(mysql_error());
define('NUMCOLS', 2);	
	$count = 0;
	$counter = 1;
echo '<table><tr><th>Name</th><th>Picture</th></tr>'; 

while($row = mysql_fetch_assoc($res)){
	if($count % NUMCOLS == 0)
	echo '<tr>';
	echo '<td>';
   		echo $row['friendname'] . "<br />". $row['image'] ."</td>";

	$count++;
	$counter++;
	if($count % NUMCOLS == 0)
	echo '</tr>'; //end row
}
echo "</table>"; 

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.