PDA

View Full Version : date and expiration display



Vindex
07-19-2003, 11:34 PM
here, you can, (i hope :oops: )
diplay, creation AND expiration date

But, dont forget to change "default_" if you have need


test it !



// for creation date
function getCreationDate($listingID)
{
// get the main data for a given listing
global $conn, $lang;
$listingID = make_db_extra_safe($listingID);

$sql = "SELECT ID, creation_date FROM default_listingsDB WHERE (default_listingsDB.ID = $listingID)";
$recordSet = $conn->Execute($sql);
if ($recordSet === false) log_error($sql);

// get main listings data
while (!$recordSet->EOF)
{
$formatted_creation = $recordSet->UserTimeStamp($recordSet->fields[creation_date],'d m Y');
$recordSet->MoveNext();
} // end while
echo "Date Added : ".$formatted_creation;
} // function getCreationDate

// for Expiration date
function getExpiration ($listingID)
{
// get the main data for a given listing
global $conn, $lang;
$listingID = make_db_extra_safe($listingID);

$sql = "SELECT ID, expiration FROM default_listingsDB WHERE (default_listingsDB.ID = $listingID)";
$recordSet = $conn->Execute($sql);
if ($recordSet === false) log_error($sql);

// get main listings data
while (!$recordSet->EOF)
{
$formatted_creation = $recordSet->UserTimeStamp($recordSet->fields[expiration],'d m Y');
$recordSet->MoveNext();
} // end while
echo "Expiration : ".$formatted_creation;
} // function getExpiration

include in "listinview.php"

<?php
getCreationDate&#40;$listingID&#41;
?>
<?php
getExpiration&#40;$listingID&#41;
?>

result here:
http://ariege-pyrenees.info/immo/listingview.php?listingID=1


PS:

i dont use ".$config[table_prefix]." because it seem to not working

with: ".$config[table_prefix]."
http://ariege-pyrenees.info/immo/listingviewDate2.php?listingID=2

without: ".$config[table_prefix]."
http://ariege-pyrenees.info/immo/listingviewDate2.php?listingID=2

sorry, but the last night, i was so tired.........
BUT, ...RealtyOne is here........... :wink:

RealtyOne
01-12-2004, 10:07 PM
To use with the configured prefix you would need to add $config to your globals .

Altered From above to work as dropin with language file use
Add to main.php before ?>



// for creation date
function getCreationDate&#40;$listingID&#41;
&#123;
// get the main data for a given listing
global $conn, $lang, $config;
$listingID = make_db_extra_safe&#40;$listingID&#41;;

$sql = "SELECT ID, creation_date FROM ".$config&#91;table_prefix&#93;."listingsDB WHERE &#40;".$config&#91;table_prefix&#93;."listingsDB.ID = $listingID&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// get main listings data
while &#40;!$recordSet->EOF&#41;
&#123;
$formatted_creation = $recordSet->UserTimeStamp&#40;$recordSet->fields&#91;creation_date&#93;,'d m Y'&#41;;
$recordSet->MoveNext&#40;&#41;;
&#125; // end while
echo "".$lang&#91;'diaplay_date_added'&#93;." &#58; ".$formatted_creation;
&#125; // function getCreationDate

// for Expiration date
function getExpiration &#40;$listingID&#41;
&#123;
// get the main data for a given listing
global $conn, $lang, $config;
$listingID = make_db_extra_safe&#40;$listingID&#41;;

$sql = "SELECT ID, expiration FROM ".$config&#91;table_prefix&#93;."listingsDB WHERE &#40;".$config&#91;table_prefix&#93;."listingsDB.ID = $listingID&#41;";
$recordSet = $conn->Execute&#40;$sql&#41;;
if &#40;$recordSet === false&#41; log_error&#40;$sql&#41;;

// get main listings data
while &#40;!$recordSet->EOF&#41;
&#123;
$formatted_creation = $recordSet->UserTimeStamp&#40;$recordSet->fields&#91;expiration&#93;,'d m Y'&#41;;
$recordSet->MoveNext&#40;&#41;;
&#125; // end while
echo "".$lang&#91;display_listing_Expiration&#93;." &#58; ".$formatted_creation;
&#125; // function getExpiration




include in "listingview.php"


<?php
getCreationDate&#40;$listingID&#41;
?>
<?php
getExpiration&#40;$listingID&#41;
?>

Add to your language file before final ?>


// extra Display option text
$lang&#91;'diaplay_date_added'&#93; = "Date Added";
$lang&#91;'display_listing_Expiration'&#93; = "Expiration";