Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: displaying output across page

  1. #11
    Join Date
    Nov 2006
    Location
    New York
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    i understand exactly what you mean, but I can't figure out how to impliment it. How can I repeat the element 3 times, then go to the next row.

    If I repeat the code, it gives me 3 of the same element before jumping to the next row...It isn't the html I have an issue with it is getting the php to output correctly...

    At a total loss...I know I have seen it before.

  2. #12
    Join Date
    Nov 2006
    Location
    New York
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hey and if your bored...I don't know why I am getting an unexpected T_ELSE in line 33. I don't see what I missed...
    PHP Code:
    <?
    include "connect.php";
    include 
    "admin/variables.php";
    print 
    "<body link=$link>";
    print 
    "<body vlink=$vlink>";
    print 
    "<body bgcolor=$bgcolor>";

    if(!isset(
    $_GET['EntryID'])) { ?>

        <? $piece="SELECT * FROM PIECES where EntryID='$EntryID'"?>
    <table style="text-align: center; margin: auto; width: 75%;">
        
      <tr>
         <td colspan="2">
        <? $piecequery=mysql_query($piece) or die("It died"); ?>
        <? while($pq=mysql_fetch_array($piecequery)) { ?>
         <font face="arial" size="5"><b><? echo($pg['name']); ?>
         </td>
      </tr>
      
      <tr>
         <td><img src="<? echo($pq['img2']); ?>"></td>
         <td valign='top' align='left'><? echo($pq['largetext']); ?>
         </td>
      </tr>

    <? ?>
    </table>
    <? ?>


    <?
    else if(!isset($_POST['submit'])) {


      
    $rowselect="Select * FROM PIECES order by numa LIMIT 0,12"?>
    <table style="text-align: center; margin: auto; width: 90%;">

      <tr>
        <th colspan="3">Identification Guide</th>
      </tr>
      <tr>


    <? $rowquery mysql_query($rowselect) or die("diesroot"); ?>
    <? 
    while($row mysql_fetch_array($rowquery)) { ?>


        <td style="color: black;">
          <p>
            <a href="index.php?EntryID=<? echo($row['EntryID']); ?>">
              <img src="<? echo($row['img1']); ?>" alt="<? echo $row[name?>">
            </a>
          </p>
          <p>
            <? echo($row['numa'] . '-' $row['numb'] . '-' $row['numc']); ?>
          </p>
          <p>
            <? echo($row['shorttext']); ?>
          </p>
        </td>

      </tr>
    <? ?>
    </table>
    <? ?>

  3. #13
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Oh. Every 3?

    Try this-- untested--
    PHP Code:
    <table><tr>
    <?php while ($row mysql_fetch_array($rowquery)) { ?>
    <td>
    <p>stuff <?php echo $row['data']; ?> more stuff</p>
    </td>
    <?php
    $three
    ++;
    if (
    $three == 0) echo "</tr>\n<tr>";
    }
    ?>
    </tr></table>
    May act kinda weird if you don't have a number of items divisible by three, like 4 items or 5, etc.


    To explain:
    The basic idea here is in these two lines:
    $three++;
    if ($three % 3 == 0) echo "</tr>\n<tr>";

    First, the variable "three" is just counting the number of entries already passed into the table.

    If the remainder of $three/3 is 0 (to check if it's 3, 6, 9...), then echo end row (the first row is opened either in the last loop of 3 or at the very start), a line break (so the html looks right; you can play with this more), then a start row tag (the tag is closed either in the next loop or after the loops at the end.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #14
    Join Date
    Nov 2006
    Location
    New York
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Great, thanks, I'll let you know what I come up with, but this makes sense.

  5. #15
    Join Date
    Nov 2006
    Location
    New York
    Posts
    26
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Worked as is...Thanks again.

    Quote Originally Posted by djr33 View Post
    Oh. Every 3?

    Try this-- untested--
    PHP Code:
    <table><tr>
    <?php while ($row mysql_fetch_array($rowquery)) { ?>
    <td>
    <p>stuff <?php echo $row['data']; ?> more stuff</p>
    </td>
    <?php
    $three
    ++;
    if (
    $three == 0) echo "</tr>\n<tr>";
    }
    ?>
    </tr></table>
    May act kinda weird if you don't have a number of items divisible by three, like 4 items or 5, etc.


    To explain:
    The basic idea here is in these two lines:
    $three++;
    if ($three % 3 == 0) echo "</tr>\n<tr>";

    First, the variable "three" is just counting the number of entries already passed into the table.

    If the remainder of $three/3 is 0 (to check if it's 3, 6, 9...), then echo end row (the first row is opened either in the last loop of 3 or at the very start), a line break (so the html looks right; you can play with this more), then a start row tag (the tag is closed either in the next loop or after the loops at the end.)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •