code question
Moderator: General Moderators
code question
i need to code the following in php.
find the 8 highest mem_id(s) in 'tests' table which have info in the local_icon field in the 'members' table
i basically want to display the most 8 recent users (that have user icons) on one of my pages (there name and icon). each field is in a different table, and i am unaccustomed to grabbing more than one piece of data from a db.
any suggestions would be appreciated.
find the 8 highest mem_id(s) in 'tests' table which have info in the local_icon field in the 'members' table
i basically want to display the most 8 recent users (that have user icons) on one of my pages (there name and icon). each field is in a different table, and i am unaccustomed to grabbing more than one piece of data from a db.
any suggestions would be appreciated.
this is what i have now....
$result="SELECT mem_id FROM tests ORDER BY mem_id DESC LIMIT 8";
$icon="select local_icon from members where mem_id='$result[mem_id]'";
$username="select username from tests where mem_id='$result[mem_id]'";
is $icon[0] the first icon result of the $icon array?
if i wanted to only select the top 8 mem_id(s) in 'tests' of people who have a local_icon in 'members', how would i change things?
$result="SELECT mem_id FROM tests ORDER BY mem_id DESC LIMIT 8";
$icon="select local_icon from members where mem_id='$result[mem_id]'";
$username="select username from tests where mem_id='$result[mem_id]'";
is $icon[0] the first icon result of the $icon array?
if i wanted to only select the top 8 mem_id(s) in 'tests' of people who have a local_icon in 'members', how would i change things?
assuming that works and returns 8 usernames, mem ids, and icon locations then how can i access those values to show up in my dynamic php page, i.e. how do i code in the varibles to my html printout?
here is the html i want the variables to appear in...
<td align=center width=125 height=45 valign=bottom><a href='userview.php?id=mem_id?>'><IMG src='<local_icon>' border=0><br>
<B><user_name></b></a>
here is the html i want the variables to appear in...
<td align=center width=125 height=45 valign=bottom><a href='userview.php?id=mem_id?>'><IMG src='<local_icon>' border=0><br>
<B><user_name></b></a>
Something like ...
Code: Select all
$res = mysql_query($sql);
while($row = mysql_fetch_assoc($res)){
?>
<tr>
<td align="center" width="125" height="45" valign="bottom">
<a href="userview.php?id=<?php echo $row['mem_id'] ?>"><IMG src="<?php echo $row['local_icon'] ?>" border="0"><br />
<B><?php echo $row['username'] ?></b></a>
</td>
</tr>
<?php
}
?>