2016-12-21 6 views
1
<form name="myForm" id="search" action="search.php?searching=true" method="post" > 
    <table cellspacing="2px" cellpadding="2px"><br/><br/> 
     <tr> 
      <td><?php if(!empty($row1)){ ?> 
       <input type="hidden" name="id" value="<?php echo (!empty($row1['id']))?$row1['id']:""?>"> 
       <?php }else{ ?> 
       <input type="hidden" name="save" value='1'> 
       <?php } ?> 
       <th style="float:left">First Name:&emsp;&emsp;&emsp;&emsp;&emsp;</th> 
      </td> 
      <td> 
       &emsp;&emsp;&emsp;&emsp; 
       <select name="salute" class="select" value="<?php echo (!empty($row1['salute']))?$row1['salute']:""?>"> 
        <option>Mr.</option> 
        <option>Ms.</option> 
        <option>Mrs.</option> 
        <option>Dr.</option> 
        <option>Prof.</option> 
       </select> 
       <input type="text" id="fname" name="fname" class="text" placeholder="Name is..." onblur="return validName();" onfocus="document.getElementById('fname_error').innerHTML=''"/><br/> 
       <label id="fname_error"></label> 
      </td> 
     </tr> 
     <tr> 
      <td> 
       <th style="float:left"> 
        <span><sup>*</sup></span>Last Name:&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; 
       </th> 
      </td> 
      <td> 
       <input type="text" name="lname" class="text" id="lastname" value="<?php echo (!empty($row1['lname']))?$row1['lname']:""?>" onblur="return validLname();" onfocus="document.getElementById('lastname_error').innerHTML=''"/> <br/> 
       <label id="lastname_error"></label> 
      </td> 
     </tr> 
    </table> 
    <table align="center" cellspacing="2px" cellpadding="2px"><br/><br/> 
     <tr> 
      <td> 
       <input type="submit" value="Search" name="search" id="search" />&emsp;&emsp;&emsp;&emsp; 
      </td> 
     </tr> 
    </table> 
    <table align="center" border="2" bgcolor="white" cellspacing="1px" cellpadding="20px"><br/><br/> 
     <tr bgcolor="#4d7fea"> 
      <th>Id</th> 
      <th>Name</th> 
      <th>Email</th> 
      <th>Age</th> 
      <th>Mobile</th> 
      <th>Gender</th> 
      <th>City</th> 
      <th>State</th> 
      <th>Country</th> 
      <th>Pin</th> 
      <th>City</th> 
      <th>State</th> 
      <th>Country</th> 
      <th>Pin</th><th>Actions</th> 
     </tr> 
     <?php 
      if (!empty($_REQUEST['fname'])){ 
       $params['name']=$_REQUEST['salute']." ".$_REQUEST['fname']." ".$_REQUEST['lname']; 
       $sql="SELECT * FROM test WHERE Name LIKE '%".trim($params['name'])."%'"; 
       $records=$db->mysqli_fetch_assoc($sql); 
       while($row=mysqli_fetch_assoc($records)){ 
     ?> 
     <tr> 
      <td><?php echo $row['id']; ?></td> 
      <td><?php echo $row['name']; ?></td> 
      <td><?php echo $row['email']; ?></td> 
      <td><?php echo $row['age']; ?></td> 
      <td><?php echo $row['mobile']; ?></td> 
      <td><?php echo $row['gender']; ?></td> 
      <td><?php echo $row['city']; ?></td> 
      <td><?php echo $row['state']; ?></td> 
      <td><?php echo $row['country']; ?></td> 
      <td><?php echo $row['pin']; ?></td> 
      <td><?php echo $row['city1']; ?></td> 
      <td><?php echo $row['state1']; ?></td> 
      <td><?php echo $row['country1']; ?></td> 
      <td><?php echo $row['pin1']; ?></td> 
      <td><a href="index.php?edit=<?php echo $row['id']; ?>"><span style='color:Purple'><b>Edit</b></span>&emsp; 
      <a href="index.php?delete=<?php echo $row['id']; ?>" onclick="return confirm('Are you Sure?')"><span style="color:Red"><b>Delete</b></span>&emsp;</td> 
     </tr> 
     <?php } }else{ ?> 
     <tr><b>No Data Found</b></tr> 
     <?php } ?> 
    </table> 
    <br/><br/><br/><br/> 
+0

問題は何ですか? – Hassaan

+0

何が問題なのですか?あなたは実際に何をしていますか?検索フォームコードはどこですか? –

+0

このクエリは機能していません – himani

答えて

2

検索文字列を使用して検索フォームを作成します。

$sql="SELECT * FROM test WHERE Name LIKE '%".trim($params['name'])."%'"; 
+0

私はそれを試して..検索で働いていない。 – himani

0
<?php if (!empty($_REQUEST['fname'])){ 
        $params['name']=$_REQUEST['salute']." ".$_REQUEST['fname']." ".$_REQUEST['lname']; 
        $sql="SELECT * FROM test WHERE Name LIKE '%".trim($params['name'])."%'"; 

        $records=mysqli_query($db->conn,$sql); 
          while($row=mysqli_fetch_assoc($records)){ ?> 
関連する問題