display php search results in html table -


im running php script , not quite getting result want. @ moment giving me output

scuba tank

mike

0.00 450.00 5.00

2012-06-04 18:50:22

scuba tank

liam

80.00 350.00 2.50

2012-06-04 19:00:09

displaying 3 results

scuba tank

josh

410.00 0.00 5.00

2012-06-04 19:00:09

its pretty want except line displaying 3 results should displayed @ end instead of before last entry. need script fix this?

<?php     $host = "localhost";     $user = "root";     $pass = null;      // ========================================     $dbhost = @mysql_connect($host, $user, $pass) or die("unable connect server");      @mysql_select_db("divebay") or die("unable select database");      $var = "scuba";     $query = trim($var);      if(!isset($query)){         echo "your search invalid";         exit;     } //line 18      $sql = "select * auction name '%" . $query . "%'";      $result = mysql_query($sql);     $numrows = mysql_num_rows($result);     mysql_close($dbhost);      if($numrows == 0){         echo "sorry, search did not return results";     }      $i = 0;      while($i < $numrows){         $row = mysql_fetch_array($result);          $id = $row['id'];         $name = $row['name'];         $owner = $row['owner'];         $holder = $row['holder'];         $start = $row['sprice'];         $current = $row['cprice'];         $instant = $row['iprice'];         $inc = $row['incprice'];         $image = $row['img'];         $time = $row['stime'];         $length = $row['duration'];          echo "             <?xml version = '1.0' encoding = 'utf-8'?>             <!doctype html public '-//w3c//dtd xhtml 1.0 transitional//en' 'http://www.w3.org    /tr/xhtml1/dtd/xhtml1-transitional.dtd'>             <html xmlns='http://www.w3.org/1999/xhtml'>             <head>                 <title>searchdbresults</title>             </head>              <body>                   <table style='width = 800px;'>                     <tr style ='height = 200px;'>                         <td style ='width = 200px;'></td>                          <td style ='width = 300px;'>                             <div style ='180px'> $name </div>                             <div> $owner </div>                         </td>                          <td style='width =200px'>                             <div style='height = 100px'> $current </div>                             <div style='height = 50px'> $instant </div>                             <div> $inc </div>                         </td>                          <td> $time </td>                     </tr>         ";          $i++;        }      echo "                 <tr> displaying $numrows results</tr>             </table>         </body>         </html>     "; ?> 

i can't comment, there several problems in code.

1st style must double quote

<div style="width:100%;">  

for example.

2nd : there must td inside tr line : displaying $numrows results

and last 1 see : have :

<?xml version = '1.0' encoding = 'utf-8'?> <!doctype html public '-//w3c//dtd xhtml 1.0 transitional//en' 'http://www.w3.org    /tr/xhtml1/dtd/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'>  <head> <title>searchdbresults</title> </head> <body>   

inside while loop, several times in page, , must not

you have table opening in while loop, not closing. it's opened several times, opened once.

edit : need add protection sql query


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -