Hi Andy,
It looks like you're heading in the right direction, the key to getting this working is to change the field that the getRecords searches on, something like this would probably work:
//Get the last number from the URL
$urlNumValue = getLastNumberInUrl();
//Get the record based on it's reference_number
list($listingRecords, $listingDetails) = getRecords(array(
'tableName' => 'listings',
'joinTable' => 'homepages',
'where' => "`reference_number` = '$urlNumValue'",
'limit' => '1',
));
$listing = @$listingRecords[0];
if (!$listing) { print "Listing not found!"; exit; }
Note: This code won't work if your reference number also contains alpha characters. So the code works by getting the last number from the URL and setting it to $urlNumValue, then a custom where statement is used to search the database and return the record with the matching reference number.
You'll also need to change your record list page to pass the correct value, I'm guessing that your list page has link to the detail page that has a link something like this?
<a href="<?php echo $record['link']; ?>" ><?php echo $record['title']; ?></a>
You'll need to create a custom detail page link that passes the reference number:
<?php $shareLink = 'http://yoursitename.com/your-detail-page.php?'.urlencode($record['title']).'-'.intval($record['reference_number']); ?>
<a href="<?php echo $shareLink; ?>" ><?php echo $record['title']; ?></a>
So this code creates a custom link that has the reference number at the end of it as opposed to the num value.
Let me know if you have any questions on how this system works, or any issues getting it up and running.
Thanks!
Greg
Greg Thomas
PHP Programmer - interactivetools.com