Geocoder: Display photo of houses on google maps markers

4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: June 26, 2015   (RSS)

By gregThomas - June 25, 2015

Hi  noahtheark,

The issue is that the $upload variable is not being set inside of the foreach loop. You need adjust your code so that the upload variable gets set with the image details inside the foreach loop so that it gets changed for each image. I think you code will need to look something like this:

<?php foreach ($myRecords as $record): ?>
  <div id="marker_infowindow_<?php echo $record['num']; ?>">
    <table cellspacing="0" cellpadding="0" border="0" width="250" height="175">
      <tr>
        <td valign="top">
          <img src="img/nien.gif" width="250" height="1" alt="">
          <div align="center"><strong><font size="+1"><?php echo htmlspecialchars( @$record['address']); ?></font></strong></div><br />
          <div align="left"><?php echo $record['summary']; ?></div>
          <div align="center">
            <?php if($upload = @$record['uploads'][0]): ?>
              <img src="<?php echo $upload['urlPath'] ?>" width="150" height="150" border="1" alt="<?php echo $upload['info1'] ?>" /></div>   
            <?php endif; ?> 
          <div align="center">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $record['bedrooms']; ?> x Bed&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $record['bathrooms']; ?> x Bath&nbsp;&nbsp;&nbsp;&nbsp;</div>
          <div align="center"><a href="<?php echo $record['_link']; ?>"><strong>VIEW PROPERTY</strong></a></div>
        </td>
      </tr>
    </table>
  </div>
<?php endforeach ?>

The code above is example code, so you might need to make a few changes to get it working correctly (for example I'm not sure if your upload field is called uploads). 

It works by trying to set the first image in the uploads field to the upload variable, and then displaying the image if it's successful.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By noahtheark - June 25, 2015

The code works!

Thank you for helping me with my code, the team here is really good at helping out the users, and I appreiate your time and knowledge.

I am still learning Php and have made allot of improvements but as you can see I am still learning.
Any tips on learning more about php, sites or books you used to learn?

Thanks again.

By gregThomas - June 26, 2015

Thanks noahtheark. 

I really like the head first books for learning new languages:

http://www.amazon.com/Head-First-MySQL-Lynn-Beighley/dp/0596006306/

I've not actually read the PHP/MySQL one (but I've read Head First Java) and I really liked the style and the way it covered topics. 

Although I've not used it, I've heard good things about code academy:

http://www.codecademy.com/

Finally, if you're planning to use CMS Builder for a few projects, I'd recommend subscribing to the CMSB cook book:

http://thecmsbcookbook.com/

This is a resource that's been created by Jerry (a forum regular), and gives code examples for creating lots of different projects in CMS Builder.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com