Jump to content


Photo

Wildcard Search issue


  • Please log in to reply
3 replies to this topic

#1 skippyscage

skippyscage
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 24 May 2004 - 08:20 PM

I can successfully build a search page with the results displaying underneath on the same page.

The problem is when you go to this page, it displays all the records first (probably because it's trying a blank wildcard search) - when entering a search it works fine.

What I need to do is to have this page display no results on the first entry. (i.e. when the user clicks on this page)

<?php
$colname_qSearch = "1";
if (isset($HTTP_POST_VARS['search'])) {
  $colname_qSearch = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['search'] : addslashes($HTTP_POST_VARS['search']);
}
mysql_select_db($database_base2, $base2);
$query_qSearch = sprintf("SELECT *,  DATE_FORMAT(endtime, '%%d %%b %%y') AS cdate, DATE_FORMAT(date, '%%d %%b %%y') AS fdate FROM turnover WHERE title LIKE '%%%s%%' ORDER BY `date` ASC", $colname_qSearch);
$qSearch = mysql_query($query_qSearch, $base2) or die(mysql_error());
$row_qSearch = mysql_fetch_assoc($qSearch);
$totalRows_qSearch = mysql_num_rows($qSearch);
?>

<form name="form1" method="post" action="">
  <input name="search" type="text" id="search">
</form>
 <?php do { ?>
<table border="0"><tr><th class="bgsolid"><?php echo $row_qSearch['sys']; ?></th></tr></table>
<table border="0">
  <tr valign="top"><td><?php echo $row_qSearch['fdate']; ?> <?php echo $row_qSearch['pmx']; ?> <span class="rb"><?php echo $row_qSearch['title']; ?></span></td></tr>
  <tr valign="top"><td><?php echo nl2br($row_qSearch['comments']); ?></td></tr>
  <tr valign="top"><td><strong><?php echo $row_qSearch['status']; ?></strong> <?php echo $row_qSearch['cdate']; ?></td></tr>
  <?php } while ($row_qSearch = mysql_fetch_assoc($qSearch)); ?>
</table>



#2 leeroy1

leeroy1
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 26 May 2004 - 06:05 PM

As a newbee i just created a page like that myself a couple months ago. Just set the defaults for the parameters to 9999999999 or some record that doesn't exist. That way records will not show up when the page first opens. Also, use the server behaviour that hides results if no records exist can help make the page look better too.

#3 skippyscage

skippyscage
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 May 2004 - 06:03 PM

so where would this default param be coded?

#4 khan kaka

khan kaka
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts
  • Locationaustralia

Posted 01 July 2004 - 06:44 AM

set the defult value to 1 or 2 in that case when the page is run it will show no results.


khan kaka




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users