Results 1 to 3 of 3
  1. #1
    Join Date
    May 2013
    Posts
    14

    Unanswered: Recordset repeat regions

    Bit of a newbie here, so apologies if I'm not quite using the correct terms, but I'm still learning!

    I have am creating a site of numerous pages on which each page has a hidden div containing a glossary. Revealing the div will show two columns with 6 items on each column.

    The glossary items are in a MySQL database called glossary, with field term_id, term and definition. The code I have so far is below, but the problem with this is that the results are in rows ie like this:

    1 2
    3 4
    5 6

    when I need it to be

    1 4
    2 5
    3 6

    PHP Code:
    <?php
    $Recordset1_endRow 
    0;
    $Recordset1_columns 2// number of columns
    $Recordset1_hloopRow1 0// first row flag
    do {
        if(
    $Recordset1_endRow == 0  && $Recordset1_hloopRow1++ != 0) echo "<tr>";
       
    ?>
        <td></td>
        <td width="260" align="left" valign="top"><?php echo $row_Recordset1['term']; ?>:</td>
        <td width="10">&nbsp;</td>
        <td width="550"><?php echo $row_Recordset1['definition']; ?></td>
        <td width="3">&nbsp;</td>
        <?php  $Recordset1_endRow++;
    if(
    $Recordset1_endRow >= $Recordset1_columns) {
      
    ?>
      </tr>
      <?php
     $Recordset1_endRow 
    0;
      }
    } while (
    $row_Recordset1 mysql_fetch_assoc($Recordset1));
    if(
    $Recordset1_endRow != 0) {
    while (
    $Recordset1_endRow $Recordset1_columns) {
        echo(
    "<td>&nbsp;</td>");
        
    $Recordset1_endRow++;
    }
    echo(
    "</tr>");
    }
    ?>

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if all you are doing is stuffing a single column from each row, then I'd suggest grabbignthe data from the DB, then insert the data into a collection using an appropriate key, reset the array to the beginnign and read in key order transferring the data from the collection into the table layout as required
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Two column page - jsFiddle

    Change from <tables> to block elements.
    George
    Home | Blog

Posting Permissions

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