0

我想从文件中打印一个表格,这样非极客群体可以在没有我帮助的情况下轻松更新表格。问题是我希望表格的第一行为每列打印不同的工具提示。我如何在 php 中执行此操作,或者有更好的方法吗?

echo "<tr><th>Date Available From (TOOLTIP) </th><th> Photo (TOOLTIP)</th><th> Age (TOOLTIP)</th><th> Breed (TOOLTIP)</th>

<?php 
$tdcount = 1; $numtd = 13; // number of cells per row 
print "<table class='hovertable'>";
print "<tr><th colspan=13><h1>AVAILABLE HORSES</h1></th></tr>";
       echo "<tr><th>Date Available From  </th><th>Photo</th><th>Age</th><th>Breed</th><th>Gender</th><th>Height</th><th>Colour</th><th>Price</th><th>Bred</th><th>Training</th><th>Known soundess illness injuries</th><th>Description</th><th>Status</th></tr>";

        $f = fopen("available.txt", "r") or die("can't open file"); 
        while (!feof($f)) { 
        $arrM = explode(",",fgets($f)); 
    $row = current ( $arrM ); 
    if ($tdcount == 1) 
    print "<tr onmouseover=\"this.style.backgroundColor='#f9ce68';\" onmouseout=\"this.style.backgroundColor='#d4e3e5';\">"; print "<td>$row </td>"; 
        if ($tdcount == $numtd) { 
            print "</tr>"; 
            $tdcount = 1; 
        } else { 
            $tdcount++; 
        } 
        } 
        if ($tdcount!= 1) { 
            while ($tdcount <= $numtd) { 
                print "<td>&nbsp;</td>"; $tdcount++; 
            } print "</tr>"; 
        } 
        print "</table>"; 
    ?> 

解决它。

从 php 中拉出表格和第一行,它们不需要在那里,现在我可以按照我想要的方式将工具提示放在图像上。

感谢大家的建议!:)

4

1 回答 1

0

要部分回答您的问题,您可以使用 :
<th title='Date Available From'>Date Available From</th>,仅在 Firefox 和 IE7 中测试。

至于您关于人们自己更新字段的问题,您必须查看数据库;平面文件或 SQL。

所有标题都已添加到表格的第一行:

<?php

$tdcount = 1; $numtd = 13; // number of cells per row 
print "<table class='hovertable'>";
print "<tr><th colspan=13><h1>AVAILABLE HORSES</h1></th></tr>";
   echo "<tr><th title='Date Available From'>Date Available From  </th><th title='Photo'>Photo</th><th title='Age'>Age</th><th title='Breed'>Breed</th><th title='Gender'>Gender</th><th title='Height'>Height</th><th title='Colour'>Colour</th><th title='Price'>Price</th><th title='Bred'>Bred</th><th title='Training'>Training</th><th title='Known soundess illness injuries'>Known soundess illness injuries</th><th title='Description'>Description</th><th title='Status'>Status</th></tr>";

    $f = fopen("available.txt", "r") or die("can't open file"); 
    while (!feof($f)) { 
    $arrM = explode(",",fgets($f)); 
$row = current ( $arrM ); 
if ($tdcount == 1) 
print "<tr onmouseover=\"this.style.backgroundColor='#f9ce68';\" onmouseout=\"this.style.backgroundColor='#d4e3e5';\">"; print "<td>$row </td>"; 
    if ($tdcount == $numtd) { 
        print "</tr>"; 
        $tdcount = 1; 
    } else { 
        $tdcount++; 
    } 
    } 
    if ($tdcount!= 1) { 
        while ($tdcount <= $numtd) { 
            print "<td>&nbsp;</td>"; $tdcount++; 
        } print "</tr>"; 
    } 
    print "</table>"; 
?>
于 2013-04-25T17:25:16.320 回答