ican
06-19-2004, 08:25 PM
I wanted a mod to show Today's Listings so I used Mick's
Thank you Mick ...
FeaturedListingsHorizontalInfo to make one.
I thought I should share it so here we go.
1) Place in style.php
*** Note File edited on the 20th June 2004 ***** If you downloaded this mod before the 20th June 2004, please re-download and follow new instructions ****
function todays($num_of_listings)
{
// shows the images connected to a given image
global $conn, $lang, $config, $style;
// grab the images
$listingID = make_db_extra_safe($listingID);
$today = date('Y-m-d');
//$seed=srand((double) microtime()*1000000);
$sql = "SELECT ID, Title, creation_date FROM " . $config[table_prefix] . "listingsDB WHERE (creation_date = '.$today.') ORDER BY RAND()";
$recordSet = $conn->SelectLimit($sql, $num_of_listings, 0 );
if ($recordSet === false)
{
log_error($sql);
}
$returned_num_listings = $recordSet->RecordCount();
if ($returned_num_listings > 0)
echo "<b><h3>Today's Listings($returned_num_listings)</h3></b>";
{
print "<table border='0' width=\"95%\" cellpadding=\"1\" cellspacing=\"1\" align='center'>";
$numcols = 5;
$count = 1;
print "<tr>";
while (!$recordSet->EOF)
{
$Title = make_db_unsafe ($recordSet->fields[Title]);
$ID = make_db_unsafe ($recordSet->fields[ID]);
// GRAB THE LISTINGS IMAGE
$sql2 = "SELECT thumb_file_name FROM " . $config[table_prefix] . "listingsImages WHERE listing_id = $ID ORDER BY ID";
$recordSet2 = $conn->SelectLimit($sql2, 1, 0);
$sql3 = "SELECT field_name, field_value FROM " . $config[table_prefix] . "listingsDBElements WHERE (listing_id = $ID) ";
$recordSet3 = $conn->Execute($sql3);
if ($recordSet2 === false)
{
log_error($sql2);
}
$num_images = $recordSet2->RecordCount();
$thumb_file_name = make_db_unsafe ($recordSet2->fields[thumb_file_name]);
if ($thumb_file_name == "")
{
$thumb_file_name = "nophoto_big.jpg";
} // end if
// ******* Fix ***********
while (!$recordSet3->EOF) {
if ($recordSet3->fields[field_name] == "baths") { $baths = $recordSet3->fields[field_value]; };
if ($recordSet3->fields[field_name] == "beds") { $beds = $recordSet3->fields[field_value]; };
if ($recordSet3->fields[field_name] == "price") { $price = $recordSet3->fields[field_value]; };
$priceformatted = international_num_format($price);
$recordSet3->MoveNext();
}
// ****** End Fix ********
while (!$recordSet2->EOF)
{
// $thumb_file_name = make_db_unsafe ($recordSet2->fields[thumb_file_name]);
if ($thumb_file_name != "")
{
// GOTTA GRAB THE IMAGE SIZE
$imagedata = GetImageSize("$config[listings_upload_path]/$thumb_file_name");
$imagewidth = $imagedata[0];
$imageheight = $imagedata[1];
$shrinkage = $config[thumbnail_width]/$imagewidth;
$displaywidth = $imagewidth * $shrinkage;
$displayheight = $imageheight * $shrinkage;
} // end if
$recordSet2->MoveNext();
} // end while
$recordSet->MoveNext();
if ($count % $numcols ==0)
{
print "<td width align='left'><a href='/listingview.php?listingID=$ID'><b>$Title</b><br>";
print "<div align=\"left\"><img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"70\" width=\"100\" alt=\"$lang[click_to_learn_more]\" border=1></a><br>";
Print("<b><font size=\"1\">".$beds." Bed Rooms/".$baths." Bath Rooms</font></b><br>");
Print("<font color=\"darkred\"><b>".money_formats($priceformatted)."</b><br></font>");
echo "</div></td></tr><tr>";
}
else
{
print "<td align=\"left\"><a href=\"/listingview.php?listingID=$ID\"><b>$Title</b><br>";
print "<div align=\"left\"><img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"70\" width=\"100\" alt=\"$lang[click_to_learn_more]\" border=1></a><br>";
Print("<b><font size=\"1\">".$beds." Bed Rooms/".$baths." Bath Rooms</font></b><br>");
Print("<font color=\"darkred\"><b>".money_formats($priceformatted)."</b><br></font>");
echo "</div></td>";
} //end if
$count++;
} // end while
print "</tr></table>";
} //end if
} // end function todays
2) Place in any file you want to display it in (can even make a new file called todays.php)
******* File edited **** I forgot that I have found this bug in the featuredlistinginfo both horizantal and vertical that will not show when there is no photo so I fixed it. **********
**** please copy the attached file nophoto_big.jpg to your images/listing_photos/ folder. that will fix that issue.
<br><?php todays(8) ?>
see it here http://www.windsorrealty.ca/index.php
If there was no listing added the day you go to this link, it will not show anything (Funny, that means that the script actually works) so you just have to try it yourself and add a new listing are two.
Enjoy..[/b]
Thank you Mick ...
FeaturedListingsHorizontalInfo to make one.
I thought I should share it so here we go.
1) Place in style.php
*** Note File edited on the 20th June 2004 ***** If you downloaded this mod before the 20th June 2004, please re-download and follow new instructions ****
function todays($num_of_listings)
{
// shows the images connected to a given image
global $conn, $lang, $config, $style;
// grab the images
$listingID = make_db_extra_safe($listingID);
$today = date('Y-m-d');
//$seed=srand((double) microtime()*1000000);
$sql = "SELECT ID, Title, creation_date FROM " . $config[table_prefix] . "listingsDB WHERE (creation_date = '.$today.') ORDER BY RAND()";
$recordSet = $conn->SelectLimit($sql, $num_of_listings, 0 );
if ($recordSet === false)
{
log_error($sql);
}
$returned_num_listings = $recordSet->RecordCount();
if ($returned_num_listings > 0)
echo "<b><h3>Today's Listings($returned_num_listings)</h3></b>";
{
print "<table border='0' width=\"95%\" cellpadding=\"1\" cellspacing=\"1\" align='center'>";
$numcols = 5;
$count = 1;
print "<tr>";
while (!$recordSet->EOF)
{
$Title = make_db_unsafe ($recordSet->fields[Title]);
$ID = make_db_unsafe ($recordSet->fields[ID]);
// GRAB THE LISTINGS IMAGE
$sql2 = "SELECT thumb_file_name FROM " . $config[table_prefix] . "listingsImages WHERE listing_id = $ID ORDER BY ID";
$recordSet2 = $conn->SelectLimit($sql2, 1, 0);
$sql3 = "SELECT field_name, field_value FROM " . $config[table_prefix] . "listingsDBElements WHERE (listing_id = $ID) ";
$recordSet3 = $conn->Execute($sql3);
if ($recordSet2 === false)
{
log_error($sql2);
}
$num_images = $recordSet2->RecordCount();
$thumb_file_name = make_db_unsafe ($recordSet2->fields[thumb_file_name]);
if ($thumb_file_name == "")
{
$thumb_file_name = "nophoto_big.jpg";
} // end if
// ******* Fix ***********
while (!$recordSet3->EOF) {
if ($recordSet3->fields[field_name] == "baths") { $baths = $recordSet3->fields[field_value]; };
if ($recordSet3->fields[field_name] == "beds") { $beds = $recordSet3->fields[field_value]; };
if ($recordSet3->fields[field_name] == "price") { $price = $recordSet3->fields[field_value]; };
$priceformatted = international_num_format($price);
$recordSet3->MoveNext();
}
// ****** End Fix ********
while (!$recordSet2->EOF)
{
// $thumb_file_name = make_db_unsafe ($recordSet2->fields[thumb_file_name]);
if ($thumb_file_name != "")
{
// GOTTA GRAB THE IMAGE SIZE
$imagedata = GetImageSize("$config[listings_upload_path]/$thumb_file_name");
$imagewidth = $imagedata[0];
$imageheight = $imagedata[1];
$shrinkage = $config[thumbnail_width]/$imagewidth;
$displaywidth = $imagewidth * $shrinkage;
$displayheight = $imageheight * $shrinkage;
} // end if
$recordSet2->MoveNext();
} // end while
$recordSet->MoveNext();
if ($count % $numcols ==0)
{
print "<td width align='left'><a href='/listingview.php?listingID=$ID'><b>$Title</b><br>";
print "<div align=\"left\"><img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"70\" width=\"100\" alt=\"$lang[click_to_learn_more]\" border=1></a><br>";
Print("<b><font size=\"1\">".$beds." Bed Rooms/".$baths." Bath Rooms</font></b><br>");
Print("<font color=\"darkred\"><b>".money_formats($priceformatted)."</b><br></font>");
echo "</div></td></tr><tr>";
}
else
{
print "<td align=\"left\"><a href=\"/listingview.php?listingID=$ID\"><b>$Title</b><br>";
print "<div align=\"left\"><img src=\"$config[listings_view_images_path]/$thumb_file_name\" height=\"70\" width=\"100\" alt=\"$lang[click_to_learn_more]\" border=1></a><br>";
Print("<b><font size=\"1\">".$beds." Bed Rooms/".$baths." Bath Rooms</font></b><br>");
Print("<font color=\"darkred\"><b>".money_formats($priceformatted)."</b><br></font>");
echo "</div></td>";
} //end if
$count++;
} // end while
print "</tr></table>";
} //end if
} // end function todays
2) Place in any file you want to display it in (can even make a new file called todays.php)
******* File edited **** I forgot that I have found this bug in the featuredlistinginfo both horizantal and vertical that will not show when there is no photo so I fixed it. **********
**** please copy the attached file nophoto_big.jpg to your images/listing_photos/ folder. that will fix that issue.
<br><?php todays(8) ?>
see it here http://www.windsorrealty.ca/index.php
If there was no listing added the day you go to this link, it will not show anything (Funny, that means that the script actually works) so you just have to try it yourself and add a new listing are two.
Enjoy..[/b]