Hi,
I try to manage to do filter boxes that searchers two db-tables. I almost got it working, but my problem is that the posts in the tables that does not the search is empty, but their space in the results is visible. Here is some code and how it looks after I filter it.
Header
Body

Thanks
Markus
I try to manage to do filter boxes that searchers two db-tables. I almost got it working, but my problem is that the posts in the tables that does not the search is empty, but their space in the results is visible. Here is some code and how it looks after I filter it.
Header
<?php
JHTML::_('behavior.modal');
$search_array = array('upphandlingsNamn','iso','leverantor', 'skapadAv','fritext');
foreach ( $search_array as $search ) {
$value = JRequest::getVar($search, '' , 'post');
if ( $value ) {
if($search=='upphandlingsNamn' || $search=='iso'){
$where[] = " upphandling.$search LIKE '%$value%' ";
}
else {
$where[] = " avtal.$search LIKE '%$value%' ";
}
}
}
if ( !empty($where) ) {
global $whereStat;
$whereStat = implode(' AND ', $where);
}
?>
<div class="myform_filter" id="stylized_filter">
<div class="filterbox"><label>Avtalsområde</label><br /><input type="text" name="upphandlingsNamn" /></div>
<div class="filterbox"><label>Produkt</label><br /><input type="text" name="fritext" /></div>
<div class="filterbox"><label>ISO-kod</label><br /><input type="text" name="iso" /></div>
<div class="filterbox"><label>Leverantör</label><br /><input type="text" name="leverantor" /></div>
<div class="filterbox"><label>Ansvarig</label><br /><input type="text" name="skapadAv" /></div>
<div class="filterbox"><input class="button" type="submit" value="Sök" name="undefined" /></div>
</div>
<br />
<table class="upphTabell" width="100%">
<thead>
<tr>
<th class="small" scope="col">Avtalsområde</th>
<th class="small" scope="col">ISO-kod</th>
<th class="small" scope="col">Avtalsperiod</th>
<th class="small" scope="col">Förlängning</th>
<th class="small" scope="col">Förlängd till</th>
<th class="small" scope="col">Leverantör</th>
<th class="small" scope="col">Ansvarig</th>
</tr>
</thead>
Body
<?php
global $whereStat;
if ( $whereStat=='' ) {
$db =& JFactory::getDBO();
$query = "
SELECT upphandling.upphandlingsNamn, upphandling.iso, upphandling.AvtalsperiodStart, upphandling.AvtalsperiodStopp, upphandling.optionForl, avtal.forlangdTill, avtal.leverantor, avtal.skapadAv
FROM upphandling, avtal
WHERE upphandling.dnr = avtal.dnr AND avtal.id = $MyRow->id;
";
$db->setQuery($query);
$row = $db->loadRowList();
}
else {
$db =& JFactory::getDBO();
$query = "
SELECT upphandling.upphandlingsNamn, upphandling.iso, upphandling.AvtalsperiodStart, upphandling.AvtalsperiodStopp, upphandling.optionForl, avtal.forlangdTill, avtal.leverantor, avtal.skapadAv
FROM upphandling, avtal
WHERE upphandling.dnr = avtal.dnr AND avtal.id = $MyRow->id AND $whereStat;
";
$db->setQuery($query);
$row = $db->loadRowList();
}
?>
<tr>
<td class="small"><a class="modal" href="http://7klovern.se.preview.binero.se/index.php?option=com_chronocontact&chronoformname=Avtal_detalj&task=extra&tmpl=component&id=<?php $row2['4'] ?>" rel="{handler: 'iframe', size: {x: 600, y: 600}}"><?php echo $row['0']['0']; ?></a></td>
<td class="small"><?php echo $row['0']['1']; ?></td>
<td class="small"><?php echo $row['0']['2'].'--'.$row['0']['3'];?></td>
<td class="small"><?php echo $row['0']['4']; ?></td>
<td class="small"><?php echo $forlangd; ?></td>
<td class="small"><?php echo $row['0']['6']; ?></td>
<td class="small"><a href="mailto:<?php echo $mail;?>"><?php echo $row['0']['7']; ?></a></td>
</tr>

Thanks
Markus