Jump to content

mleeadams

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mleeadams's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Anyone...?
  2. Forgot the code in last post... // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Location where the images are stored $file_path = 'http://www.mysite.com/holidays/files/photo_big/'; $sql = mysql_query("SELECT photo_id, photo_caption_1, photo_listing FROM listing_photo WHERE photo_listing = 127 ORDER BY `photo_status_main` <> 'main' LIMIT 10"); if (mysql_num_rows($sql) > 0) { // Default numver of columns $num_cols = 2; while ($row = mysql_fetch_array($sql)) { $items[] = array('photo_id' => $row['photo_id'], 'photo_caption_1' => $row['photo_caption_1']); } // Number of items in the array $num_items = count($items); // Number of rows $num_rows = ceil($num_items / $num_cols); // Begin HTML table echo '<table width="75%">'; for ($row = 1; $row < $num_rows; $row++) { $cell = 0; // Start each new row echo '<tr>'; for ($col = 1; $col <= $num_cols; $col++) { echo '<td>'; if ($col === 1) { $cell += $row; echo '<div class="Image"><img src="'. $file_path . $items[$cell - 1]['photo_id'] .'.jpg" alt="'. $items[$cell - 1]['photo_caption_1'] .'" title="'. $items[$cell - 1]['photo_caption_1'] .'" />'; echo '<br />'; echo '<span><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">'. $items[$cell - 1]['photo_caption_1'] .'</font></span></div>'; } else { $cell += $row; echo '<div class="Image"><img src="'. $file_path . $items[$cell - 1]['photo_id'] .'.jpg" alt="'. $items[$cell - 1]['photo_caption_1'] .'" title="'. $items[$cell - 1]['photo_caption_1'] .'" />'; echo '<br />'; echo '<span><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">'. $items[$cell - 1]['photo_caption_1'] .'</font></span></div>'; } echo '</td>'; } echo '</tr>'; } echo '</table>'; } ?>
  3. Wolphie It seems to me the code is almost correct. It shows the images in 2 column´s but only 4 images. (there could be 6, 8 or 10 depending on the property) Also the 2nd image in the first row repeats in the 1st column of the 2nd row. I am guessing there is a quick fix for this. Anyone help me with this? Thanks again for all your help.
  4. This them here... http://www.spain-holiday-sun.com/holidays/templates/english/public/test.php
  5. Sorry Wolphie, not sure what you mean
  6. Try this url for the database image http://i39.tinypic.com/atu0pz.jpg
  7. Here´s the image of the database... <a href="http://tinypic.com" target="_blank"><img src="http://i39.tinypic.com/atu0pz.jpg" border="0" alt="Image and video hosting by TinyPic"></a> The images are stored in a folder and for the example property "WHERE photo_listing = 127" in our code above, photo_listing 127 has 6 images... 115.jpg 116.jpg 117.jpg 118.jpg 119.jpg 120.jpg The test page is here... http://www.spain-holiday-sun.com/holidays/templates/english/public/test1.php
  8. Not sure how to do a dump of the database! I have a screen grab of the image database but dont know how to get it to you. Whats happening is this... Pic1 Pic2 Pic2 Pic3 Then stops. The number of images for a particular property could be from 6 / 10
  9. Great, it working However, im only getting 4 of the possible 6 pictures showing. Any ideas
  10. Im now getting... On line... echo '<div class="Image"><img src="'. $file_path . $items[$cell - 1]['photo_id'] .'.jpg'" alt="'. $items[$cell - 1]['photo_caption_1'] .'" title="'. $items[$cell - 1]['photo_caption_1'] .'" />';
  11. Thanks Wolphie I am getting an error... On this line... echo '<div class="Image"><img src="'. $file_path . $items[$cell - 1]['photo_id'] .'.jpg'; .'" alt="'. $items[$cell - 1]['photo_caption_1'] .'" title="'. $items[$cell - 1]['photo_caption_1'] .'" />'; Any ideas?
  12. Thanks Wolphie I am still not sure where to put the... <img src="<?=$src?>" alt="<?=$row['photo_caption_1']?>" title="<?=$row['photo_caption_1']?>"><br> <span><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> <?=$row['photo_caption_1']?> </font> ...to display the images. Sorry, I am a beginner and I would like to see my code implemented with yours. The images are kept in a folder Regards
  13. Hi, New here. I am also relatively new to sql & php. The code below shows a 1 colmn of images with captions. Example http://www.spain-holiday-sun.com/holidays/templates/english/public/test.php Could someone be kind enough to show me a working example, using the code below to show the same pictures but in 2 columns using a table. Thanks in advance. // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Location where the images are stored $file_path = 'http://www.mysite.com/holidays/files/photo_big/'; // Fetch the data for the pictures $sql = "SELECT `photo_id`, `photo_caption_1` , `photo_listing` FROM `listing_photo` WHERE `photo_listing`= 127 LIMIT 10"; $result = mysql_query($sql) or trigger_error(mysql_query(), E_USER_ERROR); // Display each picture while($row = mysql_fetch_assoc($result)){ $src = $file_path . $row['photo_id'] . ".jpg"; ?> <div class="Image"> <img src="<?=$src?>" alt="<?=$row['photo_caption_1']?>" title="<?=$row['photo_caption_1']?>"><br> <span><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> <?=$row['photo_caption_1']?> </font></span> </div> <?php } ?>
×
×
  • 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.