Forums

Created a Search but returns an error....help

pmsquillace 03 Jul, 2009
Hello All:

I created a simple WHERE statement based on some examples in the forum as shown here:

<?php
if(JRequest::getVar('startdate')){
?>
WHERE date > <?php echo JRequest::getVar('startdate'); ?>
<?php
}
?>


Then a simple search box of <b>Search</b>: <input type="text" name="startdate">



but when you search on the site I get this returned:

Unknown column 'date' in 'where clause' SQL=SELECT count(*) FROM jos_chronoforms_contractor_resume_form WHERE date > 06/26/2009Unknown column 'date' in 'where clause' SQL=SELECT count(*) FROM jos_chronoforms_contractor_resume_form WHERE date > 06/26/2009



I cannot seem to get this search to work even when there ARE the right variables in the WHERE statement.


thanks for any help on this,

Paul
pmsquillace 04 Jul, 2009
ok, so basically I found a post here in the forum after the fact....as usual. LOL...

I put this in the WHERE part of my form
<?php
$search_array = array('application', 'state', 'emr_soft_vend'); 
$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);
}?>


and then just made a simple search box with the same name.
<div style="float:left">
Search for a <b>Application</b>: <input type="text" name="application">
<input type="submit" value="Search" name="undefined" style='width:80px; color:#cccccc; background-color:#222222; cursor:pointer;' /></div>



My only issue is I want it to say something if it finds nothing like, your search returned no results.

Any thoughts from anyone on this would be great

Paul
GreyHead 05 Jul, 2009
Hi Paul,

Please see this post for a way of showing a 'No results found' message.

Bob
pmsquillace 05 Jul, 2009
Whoot! Thanks Bob it worked.

I just had to play around with some formatting to make it look pretty instead of the message being right up against the submit button


Thanks again for the help.

Paul
This topic is locked and no more replies can be posted.