Jump to content

Recommended Posts

In the below example, where "slide 1" is, I need to make that line automatically increase with each line that the array produces.  So in the rendered code it will be

 

<li class="example_6_item"><a href="#"><img src="/properties/large/image1.jpg" alt="slide 1 " /></a></li>

<li class="example_6_item"><a href="#"><img src="/properties/large/image2.jpg" alt="slide 2 " /></a></li>

<li class="example_6_item"><a href="#"><img src="/properties/large/image3.jpg" alt="slide 3 " /></a></li>

 

Any suggestions?

 

Thanks

Andy

 

Here is the full code

 

HERE;
if ($photos_array) {
foreach ($photos_array as $filename) {
echo <<<HERE
<script type="text/javascript">
<!--
  viewer.add('/properties/large/$filename');
  //--></script>
HERE;
if ($property_array['status_id']==5) echo '<img src="/images/sold.png" width="100" height="30" alt="" border="0" class="property-overlay" />';
elseif ($property_array['status_id']==4) echo '<img src="/images/under_offer.png" width="156" height="30" alt="" border="0" class="property-overlay" />';
echo <<<HERE

<li class="example_6_item"><a href="#"><img src="/properties/large/$filename" alt="slide 1 " /></a></li> 

HERE;
}
} else {
echo <<<HERE
<li><img src="/properties/small/noimage.jpg" border="0"></li>
HERE;
}
echo <<<HERE

Link to comment
https://forums.phpfreaks.com/topic/73930-solved-small-one/
Share on other sites

Thank you, but unfortunately that doesn't seem to work. :(

 

Here is the page in question:  http://www.brightsale.co.uk/property2.php?property_id=55250

 

And below is the full page code if that helps any more.  PS, it is the alt tag I need to produce a sequential number for, not the image name as that is generated anyway.

 

Thanks again.

 

<?php
include('class.user.php');
include('class.property.php');
include('phpmailer/class.phpmailer_custom.php');

$user=new user();
$user_id=$user->get_user_id();
$user_postcode=$user->get_postcode();
$template=new template($user);

$property_id=$_GET['property_id'];

if (! empty($_POST['no_view'])) {
# Alert admin of user feedback
$mail=new phpmailer_custom();
$mail->send_mail(ADMIN_EMAIL, "BrightSale alert: $property_id User Feedback", $_POST['no_view']);
} else {
# Record this viewing
mysql_query("UPDATE property_active SET web_views=web_views+1 WHERE property_id=$property_id;");
}

# Get the property details & images
$sql="SELECT *, property_active.property_id AS property_id, CONCAT_WS(', ', property_address_1, NULLIF(property_address_2, ''), NULLIF(property_address_3, ''), property_town, property_county) AS property_address, IFNULL(user_watching.property_id, 0) AS watching, CASE rental_furnished WHEN 'F' THEN 'Furnished' WHEN 'U' THEN 'Unfurnished' WHEN 'P' THEN 'Part-furnished' END AS rental_furnished FROM property_active, property_types LEFT JOIN user_watching ON user_watching.property_id=$property_id AND user_watching.user_id=$user_id LEFT JOIN user_ratings ON user_ratings.property_id=$property_id AND user_ratings.user_id=$user_id WHERE property_active.property_id=$property_id AND property_types.type_id=property_active.type_id;";
$property_result=mysql_query($sql) or trigger_error(mysql_error() . "<p>$sql</p>", E_USER_ERROR);
$property_array=mysql_fetch_array($property_result);

$sql="SELECT * FROM property_active_files WHERE property_id=$property_id ORDER BY top DESC, file_id ASC, file_type ASC;";
$files_result=mysql_query($sql) or trigger_error(mysql_error() . "<p>$sql</p>", E_USER_ERROR);
if (mysql_num_rows($files_result)) {
while($row=mysql_fetch_array($files_result)) {
if ($row['file_type']==1) $photos_array[]=$row['filename'];
if ($row['file_type']==2) $floorplans_array[]=$row['filename'];
if ($row['file_type']==3) $brochures_array[]=$row['filename'];
}
}


$postcode=urlencode($property_array['property_postcode']);
//START EDIT - Luke Henderson 24/01/2007
$gmap_postcode = $property_array['property_postcode'];
//END EDIT - Luke Henderson 24/01/2007

$template->section_1("House For Sale {$property_array['property_address']}");
echo <<<HERE
<script src="/javascript/ratings.js" type="text/javascript"></script>
<script type="text/javascript" src="/javascript/slide.js"></script>
<script type="text/javascript">
<!--
  var viewer = new PhotoViewer();
  viewer.setShadeColor('#b3dfff');
  viewer.setSlideDuration(4000);
viewer.disablePanning();
  viewer.enableAutoPlay();
  //--></script>
HERE;
$template->section_2();
$price='£' . ($property_array['price'] ? number_format($property_array['price']) : number_format($property_array['rental_rent']));
echo <<<HERE
<!--<div id="searchmeta"><div id="search-info"><a href="#" title="Back to Results">Back to Search Results</a></div></div>-->

<!-- Property result code -->
<h1>{$property_array['property_address']}</h1><h2>$price</h2>

<h3>{$property_array['bedrooms']} Bedrooms, {$property_array['type']} | Ref. {$property_array['property_id']}

HERE;
if ($property_array['rental_rent']) {
echo <<<HERE
<ul>
<li>Minimum term: {$property_array['rental_min_term']}</li>
<li>Maximum term: {$property_array['rental_max_term']}</li>
<li>{$property_array['rental_furnished']}</li>
<li>Deposit amount: £{$property_array['rental_deposit']}</li>
<li>Maintenance fee: £{$property_array['rental_maintenance']}</li>
</ul>
HERE;
}

echo <<<HERE
</h3>
<p>{$property_array['short_description']}</p>
{$property_array['long_description']}

<!-- END Property result code -->

HERE;
// Calendar code
/*if ($user->get_group()) {*/
$timestamp=($_GET['timestamp'] ? $_GET['timestamp'] : mktime(0, 0, 0, date('m'), date('d'), date('y')));
$timestamp=(date('w', $timestamp)==1 ? $timestamp : strtotime('last monday'));
$previous_timestamp=strtotime('last monday', $timestamp);
$next_timestamp=strtotime('next monday', $timestamp);
$event_definitions=array('u'=>' ', 'a'=>"I'm free", 'v'=>"I'm viewing", 's'=>"I'm showing");
$events=array();
$sql="SELECT * FROM user_events WHERE property_id=$property_id AND (event='a' OR event='s');";
$events_result=mysql_query($sql) or trigger_error(mysql_error() . "<p>$sql</p>", E_USER_ERROR);
if (mysql_num_rows($events_result)) {
while ($row=mysql_fetch_array($events_result)) {
$events[$row['timestamp']]=$row['event'];
}
}
$month=date('F', $timestamp) . ((date('Y', $timestamp)) != date('Y', strtotime('sunday', $timestamp)) ? ' ' . date('Y', $timestamp) : '') . ((date('F', $timestamp)) != date('F', strtotime('sunday', $timestamp)) ? ' / ' . date('F', strtotime('sunday', $timestamp)) : '') . ' ' . date('Y', strtotime('sunday', $timestamp));
echo <<<HERE
<h2><a name="book-a-viewing">Book A Viewing</a></h2>
<p>Simply click free slot below to reserve that time. Viewings are booked immediately.  If you cannot see any available time slots, you can <a href="/control-panel/send-message.php?property_id={$property_array['property_id']}">Ask the Seller</a> if they have any available timeslots. Or you can call our viewings team on 0800 231 6363 who can help you reserve an available slot.</a>
<div style="position: relative">
<p>$month</p><p><a href="{$_SERVER['PHP_SELF']}?property_id=$property_id&timestamp=$previous_timestamp#book-a-viewing">Previous Week</a> | <a href="{$_SERVER['PHP_SELF']}?property_id=$property_id&timestamp=$next_timestamp#book-a-viewing">Next Week</a></p>
<table border="0" width="100%" id="my-calendar">
<tr>
<td width="55"></td>
HERE;
for ($dow=$timestamp; $dow < ($timestamp+604800); $dow=$dow+86400) {
echo '<td width="95">' . date('l', $dow) .  '<br />'  . date('jS', $dow) . '</td>';
}
echo '</tr>';
$seconds_elapsed=28800;
for ($h=8; $h <=21; $h++) {
$row_class=$h % 2 ? "row-1" : "row-2";
echo '<tr class="' . $row_class . '"><td>' . ($h < 12 ? $h . 'am' : ($h==12 ? 12 : ($h-12)) . 'pm') . '</td>';
for ($dow=$timestamp; $dow < ($timestamp+604800); $dow=$dow+86400) {
if (array_key_exists(($dow+$seconds_elapsed), $events)) {
if ($events[($dow+$seconds_elapsed)]=='a') {
if ($user_id) {
echo '<td><a href="javascript:void(0)" onclick="calendarConfirmViewing(' . $user_id . ', ' . $property_id . ', ' . ($dow+$seconds_elapsed) . ')" id="slot' . ($dow+$seconds_elapsed) . '">I\'m free</a></td>';
} else {
echo "<td><a href=\"/control-panel/confirm_viewing.php?property_id=$property_id\">I'm free</a></td>";
}
} else {
echo '<td><a href="javascript:void(0)">I\'m showing</a></td>';
}
} else {
echo '<td><a href="javascript:void(0)"> </a></td>';
echo '';
}
echo '</a></td>';
}
$seconds_elapsed+=3600;
echo '</tr>';
}
echo <<<HERE
</table>
<div id="event-detail" style="display: none"></div>
</div>

</div><!--End left column -->
<div id="rightside">
<div id="stars">
<img src="/images/icons/stars.png" />
</div>
<div id="plinks">
<ul>
<li><a href="#"><img src="/images/icons/calendar.png" border="0" /> Book Viewing</a></li>		
<li><a href="#"><img src="/images/icons/directions.png" border="0" /> Get Directions</a></li>		
<li><a href="#"><img src="/images/icons/favourite.png" border="0" /> Save to Favourites</a></li>		
<li><a href="#"><img src="/images/icons/contact.png" border="0" /> Contact Seller</a></li></ul>	
<ul>
<li><a href="#"><img src="/images/icons/print.png" border="0" /> Print Brochure</a></li>		
<li><a href="#"><img src="/images/icons/facebook.png" border="0" /> Share on Facebook</a></li>		
<li><a href="#"><img src="/images/icons/digg.png" border="0" /> Digg This Property</a></li>		
<li><a href="#"><img src="/images/icons/delicious.png" border="0" /> Save To del.icio.us</a></li>		
</ul>
</div>


<div id="example_6">  
    <ul id="example_6_content">  

HERE;
if ($photos_array) {
foreach ($photos_array as $filename) {
if ($property_array['status_id']==5) echo '<img src="/images/sold.png" width="100" height="30" alt="" border="0" class="property-overlay" />';
elseif ($property_array['status_id']==4) echo '<img src="/images/under_offer.png" width="156" height="30" alt="" border="0" class="property-overlay" />';
echo <<<HERE
for ($i=1; $i<=$n; $i++){
  echo '<li class="example_6_item"><a href="#"><img src="/properties/large/$filename" alt="slide ' . $i . ' " /></a></li>';
}
   

HERE;
}
} else {
echo <<<HERE
<li><img src="/properties/small/noimage.jpg" border="0"></li>
HERE;
}
echo <<<HERE
    </ul>  
    <div id="example_6_frame">  
        <ul>  

        
HERE;
if ($photos_array) {
foreach ($photos_array as $filename) {
echo <<<HERE
<script type="text/javascript">
<!--
  viewer.add('/properties/small/$filename');
  //--></script>
HERE;
if ($property_array['status_id']==5) echo '<img src="/images/sold.png" width="100" height="30" alt="" border="0" class="property-overlay" />';
elseif ($property_array['status_id']==4) echo '<img src="/images/under_offer.png" width="156" height="30" alt="" border="0" class="property-overlay" />';
echo <<<HERE
<li><a href="#"><img id="thumb0" src="/properties/small/$filename" alt="thumbnail 1" /></a></li>  

HERE;
}
} else {
echo <<<HERE
<li><img src="/properties/small/noimage.jpg" border="0"></li>
HERE;
}
echo <<<HERE

        </ul>  
    </div>  
</div>  








<div id="map"></div>
<!-- Multi Domain gMaps Script -->
<script type="text/javascript"> 
      document.write( 
         '<script src="http://maps.google.com/maps?file=api&v=2&key=' + 
         { 
            'www.brightsale.co.uk': 'ABQIAAAAD-xH3_Z4RyuD3yt2UY6W4BTpUBKB7EgmOlW_gj9aXPhu2bYKbBTOH5ZcOk_kAh3JjzfXUjHmz6JDhQ', 
            'www.brightsale.com': 'ABQIAAAAQDZso4n2el09pNeFX_a3GRSOS-XnONNPkC8KpaNlaJ-nNQyQ4hSTHj6p8Cj_Cin7E6pgjBTxTCG-6g' 
         }[location.host] + 
         '" type="text/javascript"><\/script>' ); 
   </script>
<!-- End multi domain gMaps script -->
<script type="text/javascript">
window.onload = load;
window.onunload = GUnload;
//<![CDATA[
var map;
var address = '{$gmap_postcode}';
function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
var myAjax = new Ajax.Request(
'google.php',
{
method: 'get',
parameters: 'action=postcode&temp=yes&postcode=' + escape(address),
onSuccess: setCentre.bindAsEventListener(this)
});
}
}
function setCentre(response) {
response = response.responseText;
var temp = response.split(',');
var latitude = temp[0];
var longitude = temp[1];
var point = new GLatLng(latitude, longitude);
map.setCenter(point, 14);
var marker = new GMarker(point);
map.addOverlay(marker);
//marker.openInfoWindowHtml(address);
}
//]]>
</script>
HERE;


HERE;

$template->section_3();
?>

Link to comment
https://forums.phpfreaks.com/topic/73930-solved-small-one/#findComment-373069
Share on other sites

echo <<<HERE
for ($i=1; $i<=$n; $i++){
  echo '<li class="example_6_item"><a href="#"><img src="/properties/large/$filename" alt="slide ' . $i . ' " /></a></li>';
}
   

HERE;

I'm not really sure why need these "echo <<<HERE" and "HERE;".

 

If I'm right you won't need for cycle as you already have foreach cycle.

Try like this:

Before "foreach" cycle define $i = 1;

And then in end of cycle write $i++;

It should something like this:

<?php 
$i =1;
foreach ($photos_array as $filename) {
if ($property_array['status_id']==5) echo '<img src="/images/sold.png" width="100" height="30" alt="" border="0" class="property-overlay" />';
elseif ($property_array['status_id']==4) echo '<img src="/images/under_offer.png" width="156" height="30" alt="" border="0" class="property-overlay" />';
echo '<li class="example_6_item"><a href="#"><img src="/properties/large/$filename" alt="slide ' . $i . ' " /></a></li>';
$i++;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/73930-solved-small-one/#findComment-373220
Share on other sites

My mistake...

Change this:

echo '<li class="example_6_item"><a href="#"><img src="/properties/large/$filename" alt="slide ' . $i . ' " /></a></li>';

to this:

echo '<li class="example_6_item"><a href="#"><img src="/properties/large/' . $filename . '" alt="slide ' . $i . ' " /></a></li>';

 

This should work.

Link to comment
https://forums.phpfreaks.com/topic/73930-solved-small-one/#findComment-373288
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.