getting info from a single record to display in a certain place
2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 28, 2015 (RSS)
Hello,
Is there a way I can pick and choose which records to display in which part of my page? I dont want to use a 'where' statement in my header because i want to load all records but only display certain ones.
so instead of using a foreach:
<?php foreach ($our_teamRecords as $record): ?>
Record Number: <?php echo htmlencode($record['num']) ?><br/>
Title: <?php echo htmlencode($record['title']) ?><br/>
I would like to say something like "if recordnum = 1, display title"
By claire - January 28, 2015
Hi Jeff - sure, it's very easy to do if you sort the records array by num first. Run the records through a foreach loop and copy them to a new array, setting the index to be the num of the record.
Then, wherever you want to put each record, use something like this: <?php echo $sortedRecords[1]['title']; ?>
Claire Ryan
interactivetools.com
Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/