SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    weird table display in while loop -- HELP

    Hi,

    I have a search form that displays the results properly but for some reason the table displayed in the while loop is all weird. Basically when I do a search, lets say I have 14 results -- the output displays 14 empty rows and then another 14 rows with my actual results.

    Not sure what I am doing wrong, hope someone can point me in the right direction. There is link to a screenshot of the results
    http://www.cmccutstone.com/test/image001.jpg

    my code

    Code:
    <?php
    
              $searchform = true;
    
              if (isset($_GET['search'])) {
              require('connect.php');
    
              $search_q_number= $_GET['question_number'];
              $search_q_en = $_GET['actual_question'];
              $search_a_en = $_GET['actual_answer'];
              $search_type1 = $_GET['type1'];
              $search_type2 = $_GET['type2'];
              $search_product_code = $_GET['product_code'];
    
              $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
              $query = "SELECT Question_Number, Question_EN, Answer_EN, Type1, Type2,
    Product_Code FROM table3 WHERE Question_Number like '%$search_q_number%'
    and Question_EN like '%$search_q_en%' and Answer_EN like '%$search_a_en%'
    and Type1 like'%$search_type1%' and Type2 like '%$search_type2%' and
    Product_Code like '%$search_product_code%'";
    
              $result = mysqli_query($dbc, $query);
    
              if (!$result) {
                                 printf("query error : <br/> %s\n", mysqli_error($dbc));
                       }
              $searchform = false;
    
              echo '<div align="center">';
              echo '<table border="0" cellpadding="2" cellspacing="0" align="center"
    width="100%">';
              echo '<tr align="center" width="100%" >';
              echo '<td><b>ID #</b></td>
              <td><b>Question Number</b></td>
              <td><b>Question English</b></td>
              <td><b>Question French</b></td>
              <td><b>Type 1</b></td>
              <td><b>Type 2</b></td>
              <td><b>Priority</b></td>
              <td><b>Answer English</b></td>
              <td><b>Answer French</b></td>
              <td><b>Product Code</b></td>
              ';
              echo '</tr>';
              echo '<br/></div>';
    
              //number of results
              $row_cnt = mysqli_num_rows($result);
              echo '<br/>';
              printf("<strong>There are a total of " . $row_cnt ." items matching");
              echo '</strong><br/>';
    
    
              while ($row = mysqli_fetch_assoc($result)) {
              echo "<tr bgcolor='#DAD7D7'>";
    
              echo '<td valign="top" >' . $row['log'] . '</td>';
              echo '<td valign="top" >' . $row['Question_Number'] . '</td>';
              echo '<td valign="top" >' . $row['Question_EN'] . '</td>';
              echo '<td valign="top" >' . $row['Question_FR'] . '</td>';
              echo '<td valign="top" >' . $row['Type1'] . '</td>';
              echo '<td valign="top" >' . $row['Type2'] . '</td>';
              echo '<td valign="top" >' . $row['Priority'] . '</td>';
              echo '<td valign="top" >' . $row['Answer_EN'] . '</td>';
              echo '<td valign="top" >' . $row['Answer_FR'] . '</td>';
              echo '<td valign="top" >' . $row['Product_Code'] . '</td>';
              echo '</tr>';
              }
    
              mysqli_close($dbc);
              exit();
              }
    
              if ($searchform) {
              require('searchform.php');
              }
    
    ?>

    Any ideas??????

  2. #2
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    It is hard for me to see the code because I,m using a phone but you look to have missed the ending </table> tag off this can mess with your table layouts.

  3. #3
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A lot of ending </td> are missing too in one section, validate the HTML and this might help fix the prob

  4. #4
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi thanks for the replies.

    Not sure how I missed the ending table tag but it did not make any difference, still get the same result.
    As far as missing </td> tags ... where? I don't see any

    Any other ideas??

  5. #5
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is the td's in the first row, there is also a non closed div tag, and the br tags in the middle of 2 table rows which should be changed into a tr td and use the Colspan attribute

  6. #6
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks
    Got it working


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •