0

PHP ページネーション テーブルを作成しようとしていますが、以下の形式で..

ID: データ
コメント: データ
日付: データ

しかし今、私のテーブルは次のようになっています:

ID コメント 日付
データ データ データ

ひょっとして、誰かがそれを変更する方法を教えてくれませんか? .......私のコードは次のようになりました:

<?
    $connection=Mysql_connect('XX','XX','XX');
            if(!$connection)
            {
                echo 'connection is invalid';
            }
            else
            {
                Mysql_select_db('XX',$connection);

            }
    //check if the starting row variable was passed in the URL or not
    if (!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {
      //we give the value of the starting row to 0 because nothing was found in URL
      $startrow = 0;
    //otherwise we take the value from the URL
    } else {
      $startrow = (int)$_GET['startrow'];
    }
    //this part goes after the checking of the $_GET var
    $fetch = mysql_query("SELECT * FROM products LIMIT $startrow, 10")or
    die(mysql_error());
       $num=Mysql_num_rows($fetch);
            if($num>0)
            {
            echo "<table border=0  >";
            echo "<tr><td>ID</td><td>Drug</td><td>quantity</td></tr>";
            for($i=0;$i<$num;$i++)
            {
            $row=mysql_fetch_row($fetch);


            echo "<tr>";
              echo"<td>$row[1]</td>";

              echo"<td>$row[2]</td>";
             echo"<td>$row[3]</td>";
            echo"<td >$row[5]</td>";
            echo"</tr>";
            }//for
            echo"</table>";
            }
    //now this is the link..
    echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'">Next</a>';

    $prev = $startrow - 10;

    //only print a "Previous" link if a "Next" was clicked
    if ($prev >= 0)
        echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'">Previous</a>';
    ?></td>
                   <td width="331">&nbsp;</td>
                 </tr>
               </table></td>
             </tr>
           </table>
           </td>
      </tr>
    <?php
        include("footer.php");
    ?>

すみません、今すぐ理解してください..

$row=mysql_fetch_row($fetch);
        echo "<tr>";
          echo"<td>ID:$row[1]</td>";
           echo "</tr>";
            echo "<tr>";
          echo"<td>Drug:$row[2]</td>";   echo "</tr>";  echo "<tr>";
         echo"<td>QTY:$row[3]</td>";   echo "</tr>";  echo "<tr>";
        echo"<td >Date:$row[5]</td>"
        ;echo "</tr>";  
        echo"</tr>"; echo"<tr height ='20'>";echo"</tr>";
        echo"<tr >";echo"</tr>";echo"<tr >";echo"</tr>";
        }//for
        echo"</table>";
        }
4

1 に答える 1