Hello Dave,
Thanks for your reply.
I have 2 tables ---- homepages and listings
listingscourt is not a actual field, it just returns the number of records found, not the actual records themselves.
I have a textfield in homepages -- agentname
In listings --- A pulldown (multi value) field label -- agent
which uses the hompages values(num) and labels(agentname) , I use multi value since sometimes they have co-listing.
----------------------------------------------
In the homepages viewer
Normally it displays as below
A --- 2 Listings
B --- 10 Listings
C --- 5 Listings
----------------------------------------------
And I intend to be displayed below
B --- 10 Listings
C --- 5 Listings
A --- 2 Listings
i.e. displays order by the number of listing desc
----------------------------------------------------------------
Below is the current code I used
----------------------------------------------------------------
<?php
require_once "init.php";
list($homepageRecords, $homepageDetails) = getRecords(array(
'tableName' => 'homepages',
'perPage' => '30',
));
list($listingRecords, $listingDetails) = getRecords(array(
'tableName' => 'listings',
'where' => "agent LIKE '%\t" . getNumberFromEndOfUrl()."\t%'",
));
?>
<?php foreach ($homepageRecords as $homepage): ?>
<?php
$where = "agent LIKE '%\t".intval($homepage['num'])."\t%'";
$listingsCount = mysql_select_count_from('listings', $where);
?>
<?php foreach ($homepage['uploads'] as $upload): ?>
<a href="<?php echo $homepage['_link'] ?>"><img src="<?php echo $upload['urlPath'] ?>" title="<?php echo $homepage['agentname'] ?>" alt="<?php echo $homepage['agentname'] ?>" /></a><br />
<a href="<?php echo $homepage['_link'] ?>"><?php echo $homepage['agentname'] ?></a><br/>Total <?php echo $listingsCount; ?> Listing</br>
<?php break /* only show one image */ ?>
<?php endforeach ?>
<?php endforeach ?>
-----------------------------------------------
Thanks a lot