dongqi3533 2014-05-08 08:54
浏览 15

在mysql查询中添加指向表的链接?

Can someone please show me where i am going wrong with this, i am echoing out some mysql results in a query using a table format, and i am trying to make the row of results clickable so a user can click on it an link to another page.

i dont understand why its not working

<?php include 'config.php';
         $data = mysql_query("SELECT *, TIMESTAMPDIFF(DAY, insurance_date, CURDATE()) AS expire_date FROM supplier_stats ORDER BY expire_date DESC") 
         or die(mysql_error()); 

         echo "<table class=\"table\" style=\"width:995px;  font-family: 'Lucida Grande', Tahoma, Verdana, Arial, sans-serif;
         font-size:11px;\" >

    <tr>
        <td style=\"width:100px;\">ID:</td><td>Company Name:</td><td>Company Reg No:</td><td>Owner:</td><td style=\"width:200px;\">Note:</td><td style=\"width:100px;\">Date:</td><td>Status:</td></tr>";


         while($row = mysql_fetch_array( $data )) { 
            $days = $row['expire_date'];
            $when = $days*-1; 
            $str = $row['expire_date'];
            $str2 = substr($str, 1); // "quick brown fox jumps over the lazy dog."
           if ($when <= 31){
           echo "<a href=\"test.php\"><tr><td style=\"width:100px;\"><p>".$row['id'] . "</p></td>"; 
           echo "<td style=\"width:150px;\"><p>".$row['company_name'] . "</p></td>"; 
           echo "<td style=\"width:150px;\"><p>".$row['company_reg_number'] . "</p></td>";
           echo "<td style=\"width:100px;\"><p>".$row['owner'] . "</p></td>";


           if ($days > 0) {
                echo "<td style=\"width:200px;\"><p><font color=\"red\">Insurance expired!</font>";  
                echo "<td>";
                echo date('d/m/Y',strtotime($row['insurance_date']));
      echo"</td>";
                if ($when >= 7){ echo "<font color=\"green\">{$row['expire_date']}</font> day(s)!</p></td>";  }
            } else {
              $when = $days*-1;           

              echo "<td style=\"width:200px;\"><p>Insurance expires";

              if ($when > 1){
                  if ($when >= 20){ 
                  echo " in <font color=\"green\">{$str2}</font> days</font></td>"; }
                  elseif ($when >= 8){ 
                  echo " in <font color=\"orange\">{$str2}</font> days</font></td>"; }
                  elseif ($when <= 7){ 
                  echo " in <font color=\"red\">{$str2}</font> days</font></td>"; }

              } elseif ($when >= 1){ 
                echo "<font color=\"red\"> tomorrow!</font></td>";
              }
            elseif ($when >= 0){ 

                echo "<font color=\"red\"> today!</font></p></td>";
            }

            echo "<td>";
              echo date('d/m/Y',strtotime($row['insurance_date']));


      echo"</td>";


            }

            if ($when >= 20){
                echo "<td style=\"width:150px;\"><div class=\"green_light\"></div></td>";

            }

            elseif ($when >= 8){
                echo "<td style=\"width:150px;\"><div class=\"amber_light\"></div></td>";
              }

              if ($when <= 7){
                echo "<td style=\"width:150px;\"><div class=\"red_light\"></div></td>";
              }


            echo "<tr></a>";
          }
         }

          echo "</table>"; //Close the table in HTML


        ?>
  • 写回答

3条回答 默认 最新

  • dongwei7913 2014-05-08 08:55
    关注

    it is not allowed to use the p tag within an a tag

    add this css-code to your css file

    a {
      display: block;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染