display information from url

2 posts by 2 authors in: Forums > CMS Builder
Last Post: March 7, 2012   (RSS)

Re: [4cdg] display information from url

By Damon - March 7, 2012

Hi,

Here is some code that will do what you need:

<?php $categoryNum = @$_GET["category"]; // get the category num from the URL query ?>
<?php if($categoryNum) : ?>
<?php foreach ($newsRecords as $record): ?>
<?php if($categoryNum == $record['category']) : ?>
<h1><?php echo $record['category:label'] ?></h1>
<?php break; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>


First it checks to see if is a category number in the URL query exists.

Next, it checks to see if the category number in the URL query matches a category number in the database.

And finally, if there is a match, instead of displaying the category record number, it displays the label which is the name. And uses break to only display the name once.

In the code, change $newsRecords to match what you are using.

Hope this helps! Let me know if you have any questions about this.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/