0

以下は、同じテーブルの値を表示しようとしているコードですが、異なる ID を持つ HTML テーブルの異なる列に、テーブルに 3 つの列があり、各列に個別の値が表示されるとします。

同じテーブルから表示されているデータの各列で、それぞれのIDが変更されることを望んでいます

のようなもの: ID1 の値 | ID2 | の値 ID3の値

しかし、現在、私の仕事は次のようなものです: ID1 の値 | ID1 の値 | ID1の値

次のコードを修正する方法を教えてください。

          <table width="714" height="318" border="0" align="right" cellpadding="2" cellspacing="0">
          <?php $count=0; do { 
                  { ++$count;

          ?> <tr>
            <td width="231" height="288" valign="top" background="images/viv.png"><div align="center"><img src="get.php?id=<?php echo $row_Recordset1['ID']; ?>"  width="270" height="270" /><br />
                <br />
              <a href="get_deal.php?id=<?php echo $row_Recordset1['ID']; ?>"><img src="button.png" width="182" height="36" border="0" /></a><br />
              <br />
            </div></td>
            <td width="231" valign="top" background="images/viv.png"><div align="center"><img src="get.php?id=<?php echo $row_Recordset1['ID']; ?>"  width="270" height="270" /><br />
                    <br />
                    <a href="get_deal.php?id=<?php echo $row_Recordset1['ID']; ?>"><img src="button.png" width="182" height="36" border="0" /></a><br />
                    <br />
            </div></td>
            <td width="231" valign="top" background="images/viv.png"><div align="center"><img src="get.php?id=<?php echo $row_Recordset1['ID']; ?>"  width="270" height="270" /><br />
                    <br />
                    <a href="get_deal.php?id=<?php echo $row_Recordset1['ID']; ?>"><img src="button.png" width="182" height="36" border="0" /></a><br />
                    <br />
            </div></td>
          </tr>
              <tr>
                <td height="23" valign="top">&nbsp;</td>
                <td valign="top">&nbsp;</td>
                <td valign="top">&nbsp;</td>
              </tr>
              <?php }

              } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
if ($count == 0)
            echo '<span style="font-family:Tahoma;color:white;font-size:200%">No Deals Available</span>';   ?>
        </table></td>
      </tr>
    </table>

解決策: http://www.qualitycodes.com/tutorial.php?articleid=33&title=Displaying-Records-in-Multiple-Columns-Using-PHP

4

1 に答える 1

3

$row_Recordset1['ID'];ID列を表示し続けることを意味します。ID表示する列の名前に変更する必要があります。

この場合、それらは ID1 を実行し続けるため、3 つの値がすべて ID の場合は、select でエイリアス (別の名前と呼ぶ) を実行して、 を使用できるようにする必要がありID1ますID2ID3

たとえば、現在の SQL クエリが次の場合:

select *
from tablex.....

次に、列を抽出して名前を付ける必要があります。

select tablex.ID as ID1, secondTable.ID as ID2, thirdTable.ID as ID3
from tablex.....

ID1そして、それらを、ID2およびとして参照できますID3

于 2012-06-14T20:30:12.610 に答える