Multi-Record

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 23, 2009   (RSS)

I have set up a multi-record. Right now I have two records. I only want to show the content of each record.

Below I have attached the code. Works fine but I need to know how I change it to display the second record instead of the first. And can I add a record name instead of number. If I add a number and I have 50 records and delete one, all the records will be off. Thanks.

list($couponsRecords, $couponsMetaData) = getRecords(array(
'tableName' => 'coupons',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$couponsRecord = @$couponsRecords[0]; // get first record

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
body { font-family: arial; }
.instructions { border: 3px solid #000; background-color: #EEE; padding: 10px; text-align: left; margin: 25px}
</style>
</head>
<body>



<?php echo $couponsRecord['content'] ?><br/>




</body>
</html>

Re: [Dave] Multi-Record

Hi,

That worked fine.

However, the problem I will run into is if I have 50 records and I set the code on record 48 to [font "Verdana"]'offset' => '48', that will be fine, unless I delete a record before it. So if I delete record 5, record 48 would now become record 47 and the wrong page would appear or if i had 'offset' => '50' and deleted a record leaving 49 records, 'offset' => '50' would not exist.

How can I overcome this? Is there a way to add a record name instead of a number so it would not matter if a previous record was deleted?

Re: [jasonbro] Multi-Record

By Dave - February 23, 2009

Hi jasonbro,

Yes, you can lookup a record by name or number:

list($couponsRecords, $couponsMetaData) = getRecords(array(
'tableName' => 'coupons',
'where' => " num = 3 ",
'limit' => '1',
));
$couponsRecord = @$couponsRecords[0]; // get first record


... or ...

list($couponsRecords, $couponsMetaData) = getRecords(array(
'tableName' => 'coupons',
'where' => " name = 'my coupon name' ",
'limit' => '1',
));
$couponsRecord = @$couponsRecords[0]; // get first record


Hope that helps. If that's not it, let me know some more details about what you're trying to do.
Dave Edis - Senior Developer
interactivetools.com