51 users online (0 members and 51 guests)  


  Results 1 to 2 of 2

Related

  1. Replies: 3
  2. Replies: 5
  3. Send array to another page. How?    Forum: Javascript Forum
    Replies: 0
  4. Replies: 2
  5. Replies: 7
  1. #1
    jdbennett's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2004
    Posts
    3

    Exclamation Splitting SQL array to display in two tables on same page

    Hi,
    I am trying to display the results of an SQL query in tables side by side instead of one long table. I am displing about 35 records. Here is what I am doing now.

    Connection code:
    <?php
    $dbh=mysql_connect ("localhost", "x", "x") or die ('I cannot connect to the database because: ' . mysql_error());
    mysql_select_db ("x");
    $query = "SELECT * FROM products WHERE prodnum LIKE '%00'";
    //To make a new page change the part number (in the three places nessasary, use Find and Replace)
    //and change the lens thumb images and links.
    $results = mysql_query($query) or die(mysql_error());
    ?>

    And here is the html and PHP:
    <div id="Layer2" style="position:absolute; width:578px; height:242px; z-index:1; left: 58px; top: 209px;<strong><font face="Arial, Helvetica, sans-serif"></strong>

    <table width="50%" height="45" border="1">
    <?php
    while ($row = mysql_fetch_array($results)) {
    extract ($row);
    echo "<tr>";
    echo "<td width='82'>";
    echo "<img src= $thumbImage>";
    echo "</td>";
    echo "<td width='250'>";
    echo "<a href = '$link'>";
    echo $name_frame;
    echo " ";
    echo $lens;
    echo "</td></a>
    </tr>";
    }
    ?>
    <tr>
    <td>

    </td>
    </table>
    </div></font></strong>>

    Any ideas?
    Thanks

    Here is what it looks like
    http://www.gvtest.us/bylenstemplate.php

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    How about make a counter:

    Code:
    $count = 1;
    and increment the count with each record:

    Code:
    $count++;
    and check for your 'cut-off' point

    Code:
    if ($count == 20) {
    and end the previous table and start the new one:

    Code:
    if ($count == 20) {
    echo ' </table><table width="50%" height="45" border="1">';
    }
    and of course, if you want them side by side then nest the table within two table cells.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread