Skip to content Skip to sidebar Skip to footer

Users Image And Username From Sql To Html

I need help to write user image and username from sql to html I tried this codes; $query = mysql_query('SELECT * FROM tbl_images WHERE id<''.$id.'''); $row = mysql_fetch_array($

Solution 1:

U should try a join query for username and image, so that u only have to use one query and one mysql_fetch_array()

try it like this:

$query = mysql_query("SELECT i.image, u.username FROM tbl_images i JOIN Users u ON u.id=i.id WHERE u.id<'".$id."'");
if(!$query) die("MYSQL: ".mysql_error());     

echo'<table>';
while($row = mysql_fetch_array($query)){
echo'<tr>
    <td><img height="115" width="115" src="data:image/jpeg;base64,' . base64_encode( $row['image'] ) . '"/></td>
    <td><font size="2" face="Lucida Sans Unicode" color=#EBEBEB>' .$row['username'].'</td>
    </tr>';}
echo'</table>';

but is your base64_encode correct? I think it should be decode???

Post a Comment for "Users Image And Username From Sql To Html"