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:
I have then used the following code to try and insert the homepages data:
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
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> </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> (<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:
The code I am using to try and insert the data from the accounts table is as follows:
However this is not working...
I'd be very grateful if someone could offer some help with this.
Thank you,
Greg
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
Re: [gversion] Display "homepages" data on listing page
By Jason - February 1, 2011
Hi,
By default, getRecords will take care of a join to the accounts table for you, based on the createdByUserNum field.
for example, if you wanted the email from the account that created the record:
Greg, how are your homepages records and listings records being joined? If you use this code:
You'll be able to see everything that's being returned in your query. Is it returning what you expect?
Let me know.
By default, getRecords will take care of a join to the accounts table for you, based on the createdByUserNum field.
for example, if you wanted the email from the account that created the record:
<?php echo $listingsRecord['createdBy.email'];?>
Greg, how are your homepages records and listings records being joined? If you use this code:
<?php showme($listingsRecord);?>
You'll be able to see everything that's being returned in your query. Is it returning what you expect?
Let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/