runnerjp Posted April 15, 2009 Share Posted April 15, 2009 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 Link to comment https://forums.phpfreaks.com/topic/154175-solved-showing-friends-images-in-two-colums/ Share on other sites More sharing options...
doug007 Posted April 15, 2009 Share Posted April 15, 2009 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 https://forums.phpfreaks.com/topic/154175-solved-showing-friends-images-in-two-colums/#findComment-810518 Share on other sites More sharing options...
runnerjp Posted April 15, 2009 Author Share Posted April 15, 2009 im looking for more of a name name picture picture name name picture picture name name picture picture Link to comment https://forums.phpfreaks.com/topic/154175-solved-showing-friends-images-in-two-colums/#findComment-810525 Share on other sites More sharing options...
doug007 Posted April 15, 2009 Share Posted April 15, 2009 $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 https://forums.phpfreaks.com/topic/154175-solved-showing-friends-images-in-two-colums/#findComment-810527 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.