SEARCH FORM HELP

tonythuan 27 May, 2009
Hi everybody !
I created a search form with chronoconnectivity.
it searches ok . But when i open the form, the data is displayed.
I want to invisible the data, then i enter the Key to search, the data is displayed.
please help me !
GreyHead 27 May, 2009
Hi tonythuan,

You'll need to add some PHP to the body to say "display nothing if the search field is empty"

Bob
tonythuan 27 May, 2009
Thank to your quick response .
Please show me clearly !
this is my form :
WHERE SQL "
<?php
$search_array = array( 'tenchinhanh');
$where = array();
foreach ( $search_array as $search ) {
  $value = JRequest::getVar($search, '' , 'post');
  if ( $value ) {
    $where[] = " $search LIKE '$value%' ";
  }
}
if ( !empty($where) ) {
  echo " WHERE ".implode(' AND ', $where);
}?>

Header :
<h3>Thống kê xuất tuyến</h3>
<br>
<h2><a href = "index.php?option=com_chronoconnectivity&connectionname=chinhanh_tk">Quay lại </a></h2>
<br>
<div style="float:left">
<b>Tên Chi Nhánh</b>: <input type="text" name="tenchinhanh">
<input type="submit" value="Xem" name="undefined" style='width:80px; color:#cccccc; background-color:#222222; cursor:pointer;' /></div>
<br>
<STYLE TYPE="text/css">
<!--
.darkrow, .darkrow TD, .darkrow TH
{
background-color:#99CCFF;
color: #000000;
}
-->
</STYLE>
<br>
<br>
<div style="width: 710px; height: 300px; overflow: scroll; border: 1px dashed black; background-color: #fffff;"> 
<table style="text-align: left; width: 800px;" border="1" cellpadding="2" cellspacing="0">
<tr CLASS="darkrow">
<td>Tên Chi Nhánh</td>
<td>Mã Xuất tuyến</td>
<td>Tên Xuất tuyến</td>
<td>Vị Trí Đầu</td>
<td>Vị Trí Cuối</td>
<td>Chiều Dài</td>
<td></td>
</tr>

Body :
<tr>
<td>{tenchinhanh}</td>
<td>{maxuattuyen}</td>
<td>{tenxuattuyen}</td>
<td>{vitridau}</td>
<td>{vitricuoi}</td>
<td>{chieudai}</td>
</tr>
Max_admin 28 May, 2009
Hi,

try to make your first code like:

    <?php
    $search_array = array( 'tenchinhanh');
    $where = array();
    foreach ( $search_array as $search ) {
      $value = JRequest::getVar($search, '' , 'post');
      if ( $value ) {
        $where[] = " $search LIKE '$value%' ";
      }
    }
    if ( !empty($where) ) {
      echo " WHERE ".implode(' AND ', $where);
    }else{
echo " WHERE primary_field='non_existing_value'";
}


?>

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
tonythuan 28 May, 2009
Thank you very much to your response.
I can do it successfully .
This topic is locked and no more replies can be posted.