Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: displaying output across page

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

    Default displaying output across page

    I am trying to display 3 across 12 total, but as as you can probably see from my script, it is not working that way. I am getting 3 acroos and 12 total of the first entry in the DB, then 12 of the next...
    PHP Code:
    else if(!isset($_POST['submit'])) //looking at root
    //  {

        
    $numentries=12;
        
    $start=0;

        print 
    "<table align='center' border='0' width='90%'>";    
        print 
    "<tr><td colspan='3' align='center'><b>Identification Guide</b><br><br></td></tr>";    
        
    $ptrnselect="Select * FROM PIECES order by numa LIMIT $start,$numentries"
        
    $ptrnquery=mysql_query($ptrnselect) or die("diesroot");
        while(
    $p=mysql_fetch_array($ptrnquery))
            {

    $j=0;
    $y=4;

    while (
    $j $y) {
    ++
    $j;
        print 
    "<tr>";

    $i=0;
    $x=3;

    while (
    $i $x) {
        print 
    "<td align='center' width='33%'>";
        print 
    "<a href='index.php?EntryID=$p[EntryID]'><img src='$p[img1]'></a><br>";
        print 
    "<font color='#000000'>$p[numa]-$p[numb]-$p[numc]</font><br>";
        print 
    "<font color='#000000'>$p[shorttext]</font>";

        ++
    $i;
        }
        print 
    "</td>";

        }
        print 
    "</tr>";

    How do I get it move to teh next entry each time?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ugh, more hideous code. OK.
    Code:
    else if(!isset($_POST['submit'])) {
      $numentries = 12;
      $start = 0;
    
      $query = mysql_query("select * from pieces order by numa limit $start, $numentries;");
    ?>
    <table style="text-align: center; margin: auto; width: 90%;">
      <tr>
        <th colspan="3">Identification Guide</th>
      </tr>
    <?php while($row = mysql_fetch_array($query)) { ?>
      <tr>
        <td style="color: black;">
          <p>
            <a href="index.php?EntryID=<?php echo($row['EntryID']); ?>">
              <img src="<?php echo($row['img1']); ?>" alt="You need some alt text here!">
            </a>
          </p>
          <p>
            <?php echo($row['numa'] . '-' . $row['numb'] . '-' . $row['numc']); ?>
          </p>
          <p>
            <?php echo($row['shorttext']); ?>
          </p>
        </td>
      </tr>
    <?php } ?>
    </table>
    <?php
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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

    Default

    So, it is easier to make it an html page with php in it? How does this repeat?

    Thanks Twey

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    So, it is easier to make it an html page with php in it?
    All PHP pages are HTML with PHP in them by default. It's a lot easier (and neater) to drop out of PHP parsing mode when outputting large chunks of HTML than it is to echo them all out, fiddling around escaping quotes, and ending up with an unformatted blob of HTML all on one line.
    How does this repeat?
    Code:
    <?php while($row = mysql_fetch_array($query)) { ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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

    Default

    ok, I trimmed the code down to
    PHP Code:
    <?php
    if(!isset($_POST['submit'])) {
      
    $numentries 12;
      
    $start 0;

      
    $query mysql_query("select * from pieces order by numa limit $start$numentries;");?>
    <table style="text-align: center; margin: auto; width: 90%;">

      <tr>
        <th colspan="3">Identification Guide</th>
      </tr>
    <?php while($row mysql_fetch_array($query)) { ?>
      <tr>
        <td style="color: black;">
          <p>
            <a href="index.php?EntryID=<?php echo($row['EntryID']); ?>">
              <img src="<?php echo($row['img1']); ?>" alt="<?php echo($row[name]); ?>">
            </a>
          </p>
          <p>
            <?php echo($row['numa'] . '-' $row['numb'] . '-' $row['numc']); ?>
          </p>
          <p>
            <?php echo($row['shorttext']); ?>
          </p>
        </td>
      </tr>
    <?php ?>
    </table>
    and I am getting "Parse error: syntax error, unexpected $end in /home/public_html/pieces/index.php on line 30"

    I have been working on it for an hour now, and don't have a clue what is wrong.

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

    Default

    Hmm?
    There is no "$end", and, that is 29 rows, according to how I counted... maybe I counted wrong...
    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

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

    Default

    Quote Originally Posted by djr33 View Post
    Hmm?
    There is no "$end", and, that is 29 rows, according to how I counted... maybe I counted wrong...
    You are correct, that is why I am really confused...

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

    Default

    Well, usually when it claims that there is a problem of some sort at the end of the script, there's something wrong with a loop, and it's usually that there is an endless loop or something else to do with the format of the loop being wrong, like a missing bracket...
    I am, however, not seeing any errors like this in the code. A semicolon errror can also behave like this (as can a misplaced quote), but I don't see that either.
    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

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

    Default

    Think I got it this time, Was missing the secong '}' but it is still displaying down, not across like I was origianally looking for.

    PHP Code:
    <?
    include "connect.php";
    include 
    "admin/variables.php";
    print 
    "<body link=$link>";
    print 
    "<body vlink=$vlink>";
    print 
    "<body bgcolor=$bgcolor>";

    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>
    <? $rowquery mysql_query($rowselect) or die("diesroot"); ?>
    <? 
    while($row mysql_fetch_array($rowquery)) { ?>
      <tr>
        <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>

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

    Default

    I think you just need to adjust your setup... use <td> elements within a single <tr> element for a row....

    This means that the <tr> and </tr> elements should be OUTSIDE the loop, so that you get one row containing multiple rows from the database. As is you get a <tr> and </tr> per result from the DB.
    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

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
  •