hi all im trying to place this piece of coding in a table that i iam echoing if anyone has any ideas as been trying for last god knows how long

$fetch_img1 = mysqli_fetch_array(mysqli_query($conn,"select user_image from user_images where user_id = '".$show_id."' and main_image = '1' "));
              $show_image   = $fetch_img1['user_image'];
              ?>
          <div class="box">
            <?php if($show_image != '') { ?>
            <a href="viewprofile.php?profid=<?php echo $show_id;?>&gen=<?php echo $show_gender;?>"><img src="images/user_images/smallthumb/<?php echo $show_image;?>" border="0" width="100" height="80"/></a>
            <?php } else { ?>
            <a href="viewprofile.php?profid=<?php echo $show_id;?>&gen=<?php echo $show_gender;?>"><img src="images/blank.jpg" border="0" width="100" height="80" /></a>
            <?php } ?>
          </div>

And here is the table im attempting to place it in

<table border="1" width="600">
<?php
if (mysqli_num_rows($result) > 0) {

    // output data of each row

    while($row = mysqli_fetch_assoc($result)) {
    echo '<tr>';
    }
    echo '<td colspan="2" style="">' .ucfirst($fetch_user['user_name']). ',' . ($fetch_meets['event_ltm']). '</td>';
echo '</tr>';
echo '<tr>';
echo '<td style="width: 64px; height: 64px; text-align: center">photo goes here</td>';
echo '<td width="80%"></td>';
echo '</tr>';             
}
 else {
    echo "0 results";
}

?>

</table>

Many thanx jan x

You should probably use only one sql statement.
eg:

SELECT id, firstname, surname, (select user_image from user_images where user_id=id and main_image = '1' LIMIT 1) as user_image From user_table...

So the image then comes back with the original dataset

Member Avatar for diafol

No instead of a subquery you.d use a Left Join.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.