使用PHP过滤MYSQLi查询而不是带来所有结果

时间:2018-03-21 16:56:05

标签: php mysqli

我可以使用Select * From Tickets来查找所有门票,但我似乎无法将我的结果过滤到'typeofissue'列,该列指定问题类型的PRN,OPA,WIN等

我已经尝试了很多方法来实现这一点,但它们都没有工作..

这是我目前拥有的

<form>
<select name="users" onchange="showUser(this.value)">
  <option value="">Type Of Issue:</option>
  <option value="'opal'">opal</option>
  <option value="'Printer Issue'">Printer Issue</option>
  <option value="'Windows issue'">Windows issue</option>
       </select>
</form>
<br>
<div id="txtHint"><b>Ticket will be listed here...</b></div>`

我想从我的数据库中删除过滤结果

这是我的PHP     

  error_reporting(0);

  $output = ' ';

 if(isset($_GET ['q']) && $_GET['q'] !== ' ') 
{ 
   $searchq = $_GET['q']; 

    $q = mysqli_query($conn, "SELECT * FROM Tickets WHERE keywords LIKE '%$searchq%'") or die (mysqli_error($conn));   
    $c = mysqli_num_rows($q);
    if($c == 0)
      {
        $output = 'No search results for <b>"' . $searchq . '"</b>'; 
        echo  'NO data found';
      }  

      else 
      {
          while($row = mysqli_fetch_array($q))
          {
            $typeofissue = $row['typeofissue']; 
            $referencenumber = $row['referencenumber'];
            $detaileddescription = $row['detaileddescription'];
            $prets = $row['prets'];
            $troubleshooting = $row['troubleshooting'];   
            $bemail = $row['bemail']; 
            $gate = $row['gate']; 

            $output .= '<a href=" ' . $typeofissue . '">
              <h3> ' . $referencenumber . '</h3>
              <p> ' . $detaileddescription . '</p>
              <p> ' . $prets . '</p>
              <p> ' . $troubleshooting . '</p>
              <p> ' . $bemail . '</p>
              <p> ' . $gate . '</p>

              </a>';

          }
      } 


}   
 else
      {
        header("location: ./"); 
      }
print("$output");
mysqli_close($conn);


?>

现在我相信你可以用更少的代码和更少的页面实现这一目标吗?

任何人都可以提供帮助。我甚至有更困难的任务写到DB工作..

由于

0 个答案:

没有答案