5 Replies - 1999 Views - Last Post: 17 July 2012 - 12:49 AM Rate Topic: -----

#1 airy  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 22
  • Joined: 11-July 12

Retrieve all 9 images from database into a table

Posted 16 July 2012 - 05:30 AM

How to retrieve all 9 images from database into a table of 3x3 nicely without hard coding.

I want it to be done like the picture I posted.

X substitute the image.

Attached image(s)

  • Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: Retrieve all 9 images from database into a table

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3490
  • View blog
  • Posts: 10,058
  • Joined: 08-June 10

Re: Retrieve all 9 images from database into a table

Posted 16 July 2012 - 05:33 AM

you fetch the images in the appropriate order and then put them into the cells as you write them.

but without seeing what you have already tried, I canít say where your problems are.
Was This Post Helpful? 0
  • +
  • -

#3 airy  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 22
  • Joined: 11-July 12

Re: Retrieve all 9 images from database into a table

Posted 16 July 2012 - 10:23 AM

i have a code like this
<table border="1">
<?php 
    $sql = "SELECT * FROM images ORDER BY idimages DESC  "; 
    $result = $mysqli->query($sql); 
    if ($result->num_rows != 0) 
    { 
$counter=0; 
        while ($row = $result->fetch_array(MYSQLI_ASSOC)) 
        { 
            $counter++; 
if($counter == 1){ 
?> 
<tr>
<td><img src="img/<?php echo $row['photo']; echo $row['idimages'] ?>" width="200" height="280" /></td>
<?php 
} 
if($counter == 2){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
<?php 
} 


But how do i retrieve both its shirt id (idimages) and images
Was This Post Helpful? 0
  • +
  • -

#4 airy  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 22
  • Joined: 11-July 12

Re: Retrieve all 9 images from database into a table

Posted 16 July 2012 - 10:26 AM

I have a code like this
but it just seems like hard coding right?
is there any better way?
imagines i have tons of images to retrieve into table, i would have die
<body>
<? echo $me['name']?>
<table border="1">
<?php 
    $sql = "SELECT * FROM images ORDER BY idimages DESC  "; 
    $result = $mysqli->query($sql); 
    if ($result->num_rows != 0) 
    { 
$counter=0; 
        while ($row = $result->fetch_array(MYSQLI_ASSOC)) 
        { 
            $counter++; 
if($counter == 1){ 
?> 
<tr>
<td><img src="img/<?php echo $row['photo']; echo $row['idimages'] ;?>" width="200" height="280" /></td>
<?php 
} 
if($counter == 2){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
<?php 
} 
if($counter == 3){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
</tr>

<tr>
<?php 
} 
if($counter == 4){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
<?php 
} 
if($counter == 5){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
<?php 
} 
if($counter == 6){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
</tr>


<tr>
<?php 
} 
if($counter == 7){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
<?php 
} 
if($counter == 8){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
<?php 
} 
if($counter == 9){ 
?> 
<td><img src="img/<?php echo $row['photo']; ?>" width="200" height="280" /></td>
</tr>






<?php 
}             
        } 
    } 
?>
</table>
</body>

Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8957
  • View blog
  • Posts: 33,584
  • Joined: 12-June 08

Re: Retrieve all 9 images from database into a table

Posted 16 July 2012 - 10:31 AM

Do not create duplicate topics... merging them.
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3490
  • View blog
  • Posts: 10,058
  • Joined: 08-June 10

Re: Retrieve all 9 images from database into a table

Posted 17 July 2012 - 12:49 AM

View Postairy, on 16 July 2012 - 07:23 PM, said:

But how do i retrieve both its shirt id (idimages) and images

based on your code, what do you need the ID for?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1