Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: table repeats

  1. #1
    New Coder
    Join Date
    Feb 2011
    Posts
    75
    Thanks
    9
    Thanked 2 Times in 2 Posts

    table repeats

    hello I'm having a problem where the post is repeat of the same

    here a screenshot of What I mean

    I'm sure it something silly but any help will be greatful for
    PHP Code:
    <?php 
    $groupname 
    hex2str($_GET["id"]); 
    $result mysql_query("SELECT * FROM groupboards WHERE name = '$groupname'");
    if( 
    mysql_num_rows($result) == 0) {
    echo 
    "There are no members to show";
    }
    while(
    $row mysql_fetch_array($result)) {

        
    $email =$row["email"];
        
    $result1 mysql_query("SELECT * FROM users WHERE email = '$email'");
        if(
    mysql_num_rows($result1) > 0) {
        
    $nickname mysql_result($result1,0,"username");
        }
        
    $nickepuid bin2hex($nickname);
        
        
    $result2 mysql_query("SELECT * FROM groupboards WHERE name = '$groupname'");
        if(
    mysql_num_rows($result2) > 0) {
        
    $topic mysql_result($result2,$i,"topic");
        
        
    $dateofcreation mysql_result($result2,$i,"dateofcreation");
        }
        
        
    $topicepuid bin2hex($topic);
        
    ?>
    Many Thanks For Replies and help
    WhatNot

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Of course you're going to get repeats.

    First, you get all the gameboards where groupname = x. Then you look through them, getting gameboards 1, 2, 3, 4. In each iteration of the loop, you again search for all gameboards where groupname = x, which results in 1, 2, 3, 4. But you only show the data from the first, which is 1. So it just shows 1 4 times. Is there a reason you repeat the query a second time in the loop?


  •  

    Posting Permissions

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