Dear all, I have a huge problem and cant figure it out how to resolve it. I have a mysql database. which has plenty of entries in the table. I have linked my search.php page with my database everything is working fine the data is being fetched and showing the results. the problem is for example ( I search in Paid to field Frank muller it will display the results related to frank muller, but if i type only frank it wont display anything.) I want the search to show even if i dont type full name it should still provide me the results with (frank) or if i type only (Muller) it should display frank muller. Bottom line i dont want to type the full information to get the results.

How can i fix the problem let me paste my code i have been using in dreamweaver to build the search form.

Dear all, I have a huge problem and cant figure it out how to resolve it. I have a mysql database. which has plenty of entries in the table.  I have linked my search.php page with my database everything is working fine the data is being fetched and showing the results. the problem is for example ( I search in Paid to field Frank muller it will display the results related to frank muller, but if i type only frank it wont display anything.) I want the search to show even if i dont type full name it should still provide me the results with (frank) or if i type only (Muller) it should display frank muller.  Bottom line i dont want to type the full information to get the results.

How can i fix the problem let me paste my code i have been using in dreamweaver to build the search form.

<?
// Connects to your Database
include("includes/DB.php");

mysql_connect("$host","$username","$password") or die(mysql_error()) ;
mysql_select_db($db_name) or die(mysql_error()) ;
$arr = "";
if(!empty($_REQUEST['voucher']))
    $arr .= " AND bpvno = '".$_REQUEST['voucher']."'";
if(!empty($_REQUEST['bankname']))
    $arr .= " AND bank = '".$_REQUEST['bankname']."'";
if(!empty($_REQUEST['accno']))
    $arr .= " AND acno = '".$_REQUEST['accno']."'";
if(!empty($_REQUEST['paidto']))
    $arr .= " AND paidto = '".$_REQUEST['paidto']."'";


if(!empty($_REQUEST['chkno']))
    $arr .= " AND chk = '".$_REQUEST['chkno']."'";

if(!empty($_REQUEST['totalamnt']))
    $arr .= " AND tammount = '".$_REQUEST['totalamnt']."'";

if(!empty($_REQUEST['budgetcode']))
    $arr .= " AND budjetcode0 = '".$_REQUEST['budgetcode']."'";

if(!empty($_REQUEST['projectcode']))
    $arr .= " AND prjcode0 = '".$_REQUEST['projectcode']."'";

if(!empty($_REQUEST['amount']))
    $arr .= " AND amount0 = '".$_REQUEST['amount']."'";
if(!empty($_REQUEST['descc']))
    $arr .= " AND desc0 = '".$_REQUEST['descc']."'";

$sql="SELECT * FROM `bpv` WHERE id <> 0 $arr LIMIT 0 , 100";
$result=mysql_query($sql);
?>
<link href="default.css" rel="stylesheet" type="text/css" />
<form id="form1" name="form1" method="post" action="">
<h3>Search BPV<br />
</h3>
<table width="110%" border="1" cellpadding="2" cellspacing="0" bordercolor="#75A700">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
      <tr>
        <td width="12%">BPV</td>
        <td width="38%"><input name="voucher" type="text" id="voucher" /></td>
        <td width="12%">Bank Name </td>
        <td width="38%"><input name="bankname" type="text" id="bankname" /></td>
      </tr>
      <tr>
        <td>Account no </td>
        <td><input name="accno" type="text" id="accno" /></td>
        <td>Cheque no</td>
        <td><input name="chkno" type="text" id="chkno" /></td>
      </tr>
      <tr>
        <td>Paid to</td>
        <td><input name="paidto" type="text" id="paidto" /></td>
        <td>Total Amount</td>
        <td><input name="totalamnt" type="text" id="totalamnt" /></td>
      </tr>
      <tr>
        <td>Project code </td>
        <td><input name="projectcode" type="text" id="projectcode" /></td>
        <td>Budget Code </td>
        <td><input name="budgetcode" type="text" id="budgetcode" /></td>
      </tr>
      <tr>
        <td>Description</td>
        <td><input name="descc" type="text" id="descc" /></td>
        <td>Amount </td>
        <td><input name="amount" type="text" id="amount" /></td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td><div align="right">
          <input name="Submit" type="submit" class="login-btn" value="Submit" />
        </div></td>
        <td> </td>
        <td> </td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
<p class="style1">Search Results (top 100)</p>
<table width="110%" border="1" cellpadding="2" cellspacing="0" bordercolor="#75A700">
  <tr>
    <td>ID</td>
    <td>BPV</td>
    <td>Bank Name </td>
    <td>Link</td>
    <td>Description</td>
    <td>Account No </td>
    <td>Paidto</td>
    <td>Chq No </td>
    <td>Amount</td>
    <td>Proj code</td>
    <td>Budjet Code</td>
    <td>Total Ammount</td>
  </tr>
  <?
while($row = mysql_fetch_assoc($result))
{
?>
  <tr>
    <td><?=$row['id']?></td>
    <td><?=$row['bpvno']?></td>
    <td><?=$row['bank']?></td>
    <td><a href="bpv/<?=$row['photo']?>"><img src="images/pdf.jpg" /></a></td>
    <td><?=$row['desc0']?></td>
    <td><?=$row['acno']?></td>
    <td><?=$row['paidto']?></td>
    <td><?=$row['chk']?></td>
    <td><?=$row['amount0']?></td>
    <td><?=$row['prjcode0']?></td>
    <td><?=$row['budjetcode0']?></td>
    <td><?=$row['tammount']?></td>
  </tr>
  <?
}
?>
</table>
<p> </p>

Instead of:

if (!empty($_REQUEST['paidto']))
    $arr .= " AND paidto = '".$_REQUEST['paidto']."'";

you can use:

if (!empty($_REQUEST['paidto']))
    $arr .= " AND paidto LIKE '%".$_REQUEST['paidto']."%'";

OMG!!!! THANK YOU!!!!!! THATS SUCH A GREAT HELP.... MAY GOD BLESS YOU AND YOUR FAMILY....

I WOULD APPRECIATE IF YOU CAN ALSO TELL ME HOW CAN I ADD PAGE NUMBERS FOR RESULTS
FOR EXAMPLE IF I DONT SEARCH ANYTHING I OPEN UP MY SEARCH PAGE AND ITS HAS ALREADY DISPLAYING 100 ENTRIES BY DEFAULT BUT I HAVE ALMOST 500 ENTRIES IN MY BACKEND TABLE.
I WOULD LIKE TO ADD NEXT BUTTON OPTION AT THE BOTTOM OF MY PAGE, WHEN I CLICK NEXT IT SHOULD DISPLAY NEXT 100 ENTRIES. ( JUST LIKE WHEN YOU SEARCH ON GOOGLE OR ANY SEARCH ENGINE IT WILL AT THE BOTTOM DISPLAY NUMBERS OF PAGES OR SAYS NEXT TO VIEW MORE RESULTS)

PLEASE GUIDE ME I'M USING DREAMWEAVER AND I CAN EMAIL YOU THE FILES I HAVE IN PHP SO YOU CAN TAKE A LOOK AT IT PLEASE :) IM TRYING TO ATTACH THEM HERE BUT I DONT KNOW IT SAYS FILE TYPE NOT SUPPORTED.

Next time please do not write in all capitals.

Search this forum for paging or pagination. There are plenty examples already here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.