Display "homepages" data on listing page

3 posts by 2 authors in: Forums > CMS Builder
Last Post: February 1, 2011   (RSS)

By gversion - January 31, 2011

Hello,

I am trying to insert some information about the user that has created the listing using the "homepages" table.

So on the listing detail page I would like it to say:

"This listing was posted by [contact_name] from [organisation]..."

At the top of listingDetail.php I have the following code:

<?php

require_once "init.php";

list($listingsRecordRecords, $listingsRecordDetails) = getRecords(array(
'tableName' => 'listings',
'joinTable' => 'homepages',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$listingsRecord = @$listingsRecordRecords[0];


if (!$listingsRecord) { print "listingsRecord not found!"; exit; }

?>
<?php include "include_header.php"; ?>


I have then used the following code to try and insert the homepages data:

<tr>
<td>&nbsp;</td>
<td><b>This listed was posted by</b></td>
<td><a href="<?php echo $listingsRecord['homepages._link'] ?>"><?php echo $listingsRecord['homepages.contact_name'] ?> from <?php echo $listingsRecord['homepages.organisation'] ?></a> &nbsp;(<a href="listings.php?createdByUserNum=<?php echo $listingsRecord['createdByUserNum'] ?>">View all my listings</a>)<br />Tel: <?php echo $listingsRecord['homepages.phone'] ?></td>
</tr>



However, this is not working and the homepages text is not appearing.

I would be very grateful if you could help me figure out where I have gone wrong here.

Thank you,
Greg

Re: [gversion] Display "homepages" data on listing page

By gversion - February 1, 2011

Hi,

This code (see above post) appears to actually be working.

However, I'd like to also include some information from another table called "accounts" on the same page (the listing detail page).

I think I need to join the "accounts" table (??) and have tried the following at the top of the page:


<?php

require_once "init.php";

list($listingsRecordRecords, $listingsRecordDetails) = getRecords(array(
'tableName' => 'listings',
'joinTable' => 'homepages','accounts',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$listingsRecord = @$listingsRecordRecords[0];


if (!$listingsRecord) { print "listingsRecord not found!"; exit; }

?>



The code I am using to try and insert the data from the accounts table is as follows:


<?php echo $listingsRecord['accounts.first_name'] ?>">
<?php echo $listingsRecord['accounts.last_name'] ?>">
<?php echo $listingsRecord['accounts.email'] ?>" />



However this is not working...

I'd be very grateful if someone could offer some help with this.

Thank you,
Greg