Jump to content

Displaying Images


graham23s

Recommended Posts

Hi Guys,

 

I let the users on my site upload 10 images each, when it comes to showing the images they all show horizobtally down the way i was after:

 

img1 img 2 img 3 img 4 img 5

img 6 img 7 img 8 img 9 img 10

 

what would be the best way to acomplish this do you think?

 

<?php
#################################################
# viewimages.php
#################################################

  ## id
  $usersid = $_GET['id'];
  
  $qi = "SELECT * FROM `usersphotos` WHERE `userid`='$usersid' ORDER BY `date`";
  $ri = mysql_query($qi);
  $anyimages = mysql_num_rows($ri);
  
  ## echo a back link
  echo ("<div id=\"\" align=\"left\">[<a href=\"profile.php?id=$usersid\" class=\"foot_links\">Back To Users Profile</a>]</div>");
  
  ## no uploads
  if($anyimages == 0) {
     stderr("Error","This user has no images uploaded yet.");
     include("includes/footer.php");
     exit; 
  }
  
  ## loop the images out
  while($r = mysql_fetch_array($ri)) {
  
  $imageid = $r['id'];
  $image = $r['image'];
  
  echo ("<table class=\"sub_table\" align=\"center\" width=\"250\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">");
  echo ("<tr>");
  echo ("<td class=\"header_boxes\" align=\"center\"><span class=\"prof_head\">Image ID [$imageid]</span></td>");
  echo ("</tr>");
  echo ("<tr>");
  echo ("<td bgcolor=\"#e8f1fa\" align=\"center\"><img src=\"uploads/$image\"></td>");
  echo ("</tr>");
  echo ("<tr>");
  echo ("<td bgcolor=\"#e8f1fa\" align=\"center\"> </td>");
  echo ("</tr>");
  echo ("</table><br />");  
  
  }
?>

 

thanks guys

 

Graham

Link to comment
Share on other sites

This isn't a PHP question.. its HTML/CSS question..

the problem is with your table..

 

don't loop the table over and over.. just the columns

 

ie

<?php
  ## loop the images out
$TDimages ="";
$TDimagedata ="";
  while($r = mysql_fetch_array($ri)) {
  
  $imageid = $r['id'];
  $image = $r['image'];

$TDimages .= "<td bgcolor=\"#e8f1fa\" align=\"center\"><img src=\"uploads/$image\"></td>"
$TDimagedata .= "<td class=\"header_boxes\" align=\"center\"><span class=\"prof_head\">Image ID [$imageid]</span></td>";
  
  }  
  echo ("<table class=\"sub_table\" align=\"center\" width=\"250\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">");
  echo ("<tr>");
  echo ($TDimages);
  echo ("</tr>");
  echo ("<tr>");
  echo ($TDimagedata);
  echo ("</tr>");
  echo ("<tr>");
  echo ("<td bgcolor=\"#e8f1fa\" align=\"center\"> </td>");
  echo ("</tr>");
  echo ("</table><br />");  
?>

 

(UNTESTED unchecked)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.