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 9 of 9
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Urgent Help Need Here Please Display Crisis

    HI ALL
    well am trying to display the result from the sql query that joins two tables. I tested the query it works fine in mysql and give me the required row but when i come to display it only the heading is displayed and NO ERROR MESSAGES WHAT SO EVER.


    PHP Code:
    $sql="select topics.topic_title, topics.mod_id as mt, topics.topic_creator, topics.topic_role,topics.topic_details, topics.post_timestamp as pt,posts.post_title, posts.mod_id as mp, posts.post_creator, posts.post_role,posts.post_details, posts.post_timestamp as pp
    from topics inner join posts on topics.topic_id=posts.topic_id where topics.mod_id='$mod' and topics.post_timestamp between '$start' and '$end'" 
    ;


    #executing the query2
    $result=mysql_query($sql,$myConn) or die("cannot run query <br>$sql").mysql_error();

    #if successfull display output
    if ($result){

        
        
        [
    B]#displaying the table heading.[/B]

        
    $list="<table border=\"1\" cellpadding=\"2\" align=\"center\">";
        
    $list .= "<tr  style=\" background-color:#6A006A\"><th align=\"center\" style=\" font-style:normal; color:#FFDFFF\">Article Topic</th>";
        
    $list .= "<th style=\" font-style:normal; color:#FFDFFF\">Article Content</th>";
        
    $list .= "<th style=\" font-style:normal; color:#FFDFFF\">Module</th>";
        
    $list .= "<th style=\" font-style:normal; color:#FFDFFF\">Posted By  </th>"
        
    $list .= "<th style=\" font-style:normal; color:#FFDFFF\">Role</th>";
        
    $list .= "<th style=\" font-style:normal; color:#FFDFFF\">Date</th>";
        
    $list .="</tr>";
        while (
    $row=mysql_fetch_array($result)) {[B]# displaying table records in a loop[/B]
                        
    $list .= "<tr>"
                    
                    
    $list .="<td>"$row['topic_title']."</td>";
                    
    $list .="<td>"$row['topic_details']."</td>";
                    
    $list .= "<td>"$row['mt']."</td>"
                    
    $list .="<td>".$row['topic_creator']."</td>";
                    
    $list .="<td>".$row['topic_role']."</td>";
                    
    $list .="<td>" .$row['pt']."</td>";
                    
    $list .= "</tr>";
                    
    $list .="<tr><td>Replies</td></tr>";
                    
    $list .= "<tr>";
                    
    $list .="<td>"$row['post_title']."</td>";
                    
    $list .="<td>"$row['post_details']."</td>";
                    
    $list .= "<td>"$row['mp']."</td>"
                    
    $list .= "<td>"$row['post_creator']."</td>"
                    
    $list .="<td>".$row['post_role']."</td>";
                     
    $list .="<td>" .$row['pp']."</td>";
                    
    $list .= "</tr>"
                    
                    }
                    
    mysql_free_result($result);
                  
                    
    $list .= "</table>"
    Any help will be welcomed.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Do you ever actually echo your $list variable?

  • #3
    New Coder
    Join Date
    Jul 2006
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes I do like this

    echo ($list);

  • #4
    New Coder
    Join Date
    Aug 2006
    Location
    Netherlands
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you sure that the mysql_fetch_array 2nd parameter is default set as MYSQL_ASSOC? If not, you will not get an associative array!

    Otherwise add this parameter to your fetch, as in:
    PHP Code:
    while ($row=mysql_fetch_array($resultMYSQL_ASSOC)) 
    Ronald

  • #5
    New Coder
    Join Date
    Jul 2006
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ronverdonk
    Are you sure that the mysql_fetch_array 2nd parameter is default set as MYSQL_ASSOC? If not, you will not get an associative array!

    Otherwise add this parameter to your fetch, as in:
    PHP Code:
    while ($row=mysql_fetch_array($resultMYSQL_ASSOC)) 
    i have included the mysql_assoc still no change, please more suggestions.

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    What does "echo $sql" show you?

  • #7
    New Coder
    Join Date
    Aug 2006
    Location
    Netherlands
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    To nbe sure you have any rows selected, put a
    PHP Code:
    print_r($row); 
    statement after each fetch. That way you can see if there is anything selected and what.

    Ronald
    RTFM is an almost extinct art form, it should be subsidized.

  • #8
    New Coder
    Join Date
    Jul 2006
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator
    What does "echo $sql" show you?
    it show that it picks up the right row in the topics table and the 1st reply
    its just when it cones to display and loop rounsd that the problem starts.

    [QOUTE=ronverdonk]print_r($row)[/QOUTE]

    when i added this line it prompted a response at list and i thot the way i designed the output was not right so i canged it
    to
    PHP Code:
      line 40 while ($row=mysql_fetch_array($resultMYSQL_ASSOC)) {
        
    print_r($row);
        
                        echo 
    "<tr>"
                    
                    echo
    "<td>"$row['topic_title']."</td>";
                    echo
    "<td>"$row['topic_details']."</td>";
                    echo 
    "<td>"$row['mt']."</td>"
                    echo
    "<td>".$row['topic_creator']."</td>";
                    echo
    "<td>".$row['topic_role']."</td>";
                    echo
    "<td>" .$row['pt']."</td>";
                    echo 
    "</tr>";
                    
    $my=$row['topic_title'];
                    
    $sql2"select * from posts where post_title=$my ";
                    
    $res2=mysql_query($sql2);
            
    line 55          $countmysql_num_rows($res2); 
                    for(
    $i=1;$i<=$count;$i++){
                    echo
    "<tr><td>Replies</td></tr>";
                    echo 
    "<tr>";
                    echo
    "<td>"$row['post_title']."</td>";
                    echo
    "<td>"$row['post_details']."</td>";
                    echo 
    "<td>"$row['mp']."</td>"
                    echo 
    "<td>"$row['post_creator']."</td>"
                    echo
    "<td>".$row['post_role']."</td>";
                     echo
    "<td>" .$row['pp']."</td>";
                    echo 
    "</tr>"
                    
                    }
                    
    mysql_free_result($result);
                  
                    echo 
    "</table>"
                    
          }         
             
     }  
           
              
              echo (
    "There are no user listings");
              
              } 
    but i get the following errors
    Code:
     Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /disks/diskh/zco/cohaa/public_html/tester1/gen_report.php on line 55
    -------------------
    Warning: mysql_fetch_array(): 4 is not a valid MySQL result resource in /disks/diskh/zco/cohaa/public_html/tester1/gen_report.php on line 40
    thanx.
    hmm

  • #9
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Why aren't you checking for errors on your mysql_query() functions?


  •  

    Posting Permissions

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