Filtering out Certain Records
5 posts by 2 authors in: Forums > CMS Builder
Last Post: September 21, 2010 (RSS)
Hi there, I need to filter out certain records which match:
suppress=1
from the following code, any suggestions on how I would do this?
Many thanks
Jan
suppress=1
from the following code, any suggestions on how I would do this?
<?php
$values = getListValues('yachts','destinations',$record['destinations']);
$labels = getListLabels('yachts','destinations',$record['destinations']);
$valuesToLabels = array_combine($values, $labels);
?>
<p class="destinations">Destinations: <br />
<?php $count2=0; ?>
<?php foreach ($valuesToLabels as $value => $label): ?>
<?php echo ($count2==0)? "" : ", " ?>
<a href="/destination.php/<?php echo str_replace(" ","-",strtolower($label."-".$value)); ?>/"><?php echo htmlspecialchars($label); ?></a>
<?php $count2++;?>
<?php endforeach ?>
</p>
Many thanks
Jan
Re: [aquaman] Filtering out Certain Records
By Jason - September 21, 2010
Hi Jan,
In which table would the field suppress appear? Do you need to remove those records from the entire page, or just from this one section of code?
If you could attach your entire .php page, I can take a closer look into the issue for you.
Hope this helps.
In which table would the field suppress appear? Do you need to remove those records from the entire page, or just from this one section of code?
If you could attach your entire .php page, I can take a closer look into the issue for you.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Filtering out Certain Records
Hi Jason,
just need to remove from this section of code only. The feild is in the destination table.
Have attached the page. Code snippet starts on line 96.
The page looks like this:
sailconnections.dreamhosters.com/yacht-type.php/sailing-1/
Im hoping to suppress the Mediterranean link and a few others from the list of yachts.
Many thanks
Jan
just need to remove from this section of code only. The feild is in the destination table.
Have attached the page. Code snippet starts on line 96.
The page looks like this:
sailconnections.dreamhosters.com/yacht-type.php/sailing-1/
Im hoping to suppress the Mediterranean link and a few others from the list of yachts.
Many thanks
Jan
Re: [aquaman] Filtering out Certain Records
By Jason - September 21, 2010
Hi Jan,
Since we're not actually selecting records from the destinations table, try this code (I've highlighted the changes in red):
This code assumes that the table is called "destinations". If not, you'll need to change the code to reflect that. What this is doing is for each destination number in the array, it checks if that record has suppress set to 1. If it does, it skips to the next record in the list.
Hope this helps.
Since we're not actually selecting records from the destinations table, try this code (I've highlighted the changes in red):
<?php foreach ($valuesToLabels as $value => $label): ?>
<?php
$where ="num =".intval($value)." AND suppress=1";
if(mysql_select_count_from('destinations',$where)){
continue;
}
?>
<?php echo ($count2==0)? "" : ", " ?><a href="/destination.php/<?php echo str_replace(" ","-",strtolower($label."-".$value)); ?>/"><?php echo htmlspecialchars($label); ?></a>
<?php $count2++;?>
<?php endforeach ?>
This code assumes that the table is called "destinations". If not, you'll need to change the code to reflect that. What this is doing is for each destination number in the array, it checks if that record has suppress set to 1. If it does, it skips to the next record in the list.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Filtering out Certain Records
Perfect, thanks Jason!