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 Quote Link to comment 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>"; Quote Link to comment 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 Quote Link to comment 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>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.