0

I'm quite new to PHP and I'm looking to have a ID pulled from my Database to show a Image in a table and have it alternate in each column.

Right now I have the following.

    <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="white">
        <tr bgcolor="#CCCCCC" align="center">
            <td width="36%"><h4>Image</h4></td>
        </tr>
    <?php
        $query = "SELECT * FROM retail_achievements WHERE game_id = '$gameID' && achievement_locked = '0' ORDER BY achievement_id ASC";
        $result = mysql_query($query);
        while($row = mysql_fetch_assoc($result)) {   // Start looping table row
        $gameID = $row['game_id'];
        $achievementID = $row['achievement_id'];
    ?>
        <tr align="center" bgcolor="#eeeeee">
            <td> <img src="images/achievements/<?php echo $gameID; ?>/<?php echo $achievementID; ?>.jpg" /> </td>        </tr>

    <?php
    } // end of while loop
    ?>
</table>

This will display the images one by one but I would like side by side.

Thanks for any help!

2
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by LastMitch
0

@DarkSynopsis

I assume this code works.

To do side by side, it's more CSS issue than a PHP issue. To make it side by side you need to do this <tr><td></td><td></td></tr>

From this:

<tr align="center" bgcolor="#eeeeee">
<td> 
<img src="images/achievements/<?php echo $gameID; ?>/<?php echo $achievementID; ?>.jpg" /> </td>        
</tr>

To this:

<tr align="center" bgcolor="#eeeeee">
<td> 
<img src="images/achievements/<?php echo $gameID; ?>/<?php echo $achievementID; ?>.jpg" /> 
</td>   
<td> 
<img src="images/achievements/<?php echo $gameID; ?>/<?php echo $achievementID; ?>.jpg" /> 
</td>
</tr>

Edited by LastMitch: grammer

0

Problem with that is it does not alternate the Image I end up getting

Image1 Image1
Image2 Image2

When I want

Image1 Image2
Image3 Image3

Edited by DarkSynopsis

0

@DarkSynopsis

Problem with that is it does not alternate the Image I end up getting

In order to get the image side by side. You need another column so you can separate the images.

Your Column:

$query = "SELECT * FROM retail_achievements WHERE game_id = '$gameID' && achievement_locked = '0' ORDER BY achievement_id ASC";

New Column:

"SELECT column_name1, column_name2 FROM table_name WHERE column_name=operator value"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.