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>"; 
    ?> 

修正しました。

テーブルと最初の th 行を php から引き出しました。それらはそこにある必要はありませんでした。今では、必要なように th の画像にツール ヒントを挿入するのに問題はありません。

皆さんの提案に感謝します!:)

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 に答える