php - Search query with table display -


i have page table.php here' has search displays database table in table format. code below can search , can display data not in table format. please me code make display search in table format.

   $output='';    $noresult='';                                            //collect    if (isset($_post['search']))      {         $searchq = $_post['search'];         $searchq = preg_replace("#[^0-9a-z]#i","",$searchq);          $query = mysql_query("select * transaction patientid '%$searchq%' ") or die ("could not search");         $count = mysql_num_rows($query);              if($count == 0)         {             $noresult = 'there no search results!';             } else                  {                            while($row = mysql_fetch_array($query))                      {                     $tranid = $row['tranid'];                     $trandate = $row['trandate'];                     $trandescription = $row['trandescription'];                     $tranquantity = $row['tranquantity'];                     $tranunitprice= $row['tranunitprice'];                     $tranamount = $row['tranamount'];                      $output .= '<div>'.$tranid.''.$trandescription.'</div>';         }       }     }      ?>           

try following:

echo "<table>     <tr>         <th scope='col'>id</th>         <th scope='col'>date</th>         <th scope='col'>description</th>         <th scope='col'>quantity</th>         <th scope='col'>unit price</th>         <th scope='col'>amount</th>     </tr>"; while($row = mysql_fetch_array($query)) {     echo "         <tr>             <td>".$row['tranid']."</td>             <td>".$row['trandate']."</td>             <td>".$row['trandescription']."</td>             <td>".$row['tranquantity']."</td>             <td>".$row['tranunitprice']."</td>             <td>".$row['tranamount']."</td>         </tr>     "; } echo "</table>"; 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -