vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   query not returning enough info (https://vborg.vbsupport.ru/showthread.php?t=74400)

sabret00the 01-15-2005 02:48 PM

query not returning enough info
 
PHP Code:

    $posts $DB_site->query("
         SELECT grps_post.postid, grps_post.groupid, grps_post.username AS postusername, grps_post.ipaddress AS ip, grps_post.title AS posttitle, grps_post.dateline, grps_post.pagetext, grps_post.iconid, icon.title AS icontitle, icon.iconpath, grps_post.visible, grps.leaderid, user.*, userfield.*, usertextfield.*, avatar.avatarpath, NOT ISNULL(customavatar.avatardata) AS hascustomavatar, customavatar.dateline AS avatardateline 
         FROM grps_post
         LEFT JOIN grps ON (grps.groupid = grps_post.groupid)
         LEFT JOIN " 
TABLE_PREFIX "user ON (user.userid = grps_post.userid)
         LEFT JOIN " 
TABLE_PREFIX "userfield AS userfield ON(userfield.userid = user.userid)
         LEFT JOIN " 
TABLE_PREFIX "usertextfield ON (usertextfield.userid = user.userid)
         LEFT JOIN " 
TABLE_PREFIX "icon ON (icon.iconid = grps_post.iconid)
         LEFT JOIN " 
TABLE_PREFIX "avatar AS avatar ON(avatar.avatarid = user.avatarid)
         LEFT JOIN " 
TABLE_PREFIX "customavatar AS customavatar ON(customavatar.userid = user.userid)
 
         WHERE grps_post.groupid = 
$groupid AND grps_post.visible != 0
         GROUP BY grps_post.groupid
         ORDER BY grps_post.dateline DESC
     "
); 

i know theirs four rows in the tables where the group id = 6 so i'm using this as an example, but it's still only returning on row for some reason even when i use phpmyadmin to run the query.

Marco van Herwaarden 01-15-2005 03:02 PM

This will return only 1 row if all those 4 rows have the same groupid.

You are grouping together all with the same groupid with the statement:
[sql]GROUP BY grps_post.groupid
[/sql]

Surprised it don't give an error.

sabret00the 01-15-2005 03:27 PM

thanks for that

although it now it seems to the be the loop that's causing it to only show one row

PHP Code:

    while ($post $DB_site->fetch_array($posts))
    {
        
$cell++;
        
$template iif($post['isdeleted'], "postbit_deleted""groups_viewthread_postbit");
        
// lets work out the age
        
if (!$year)
        {
            
$year vbdate('Y'TIMENOWfalsefalse);
            
$month vbdate('n'TIMENOWfalsefalse);
            
$day vbdate('j'TIMENOWfalsefalse);
        }

        if (empty(
$gotage["$post[userid]"]))
        {
            
$date explode('-'$post['birthday']);
            if (
$year $date[2] AND $date[2] != '0000')
            {
                
$post['age'] = $year $date[2];
                if (
$month $date[0] OR ($month == $date[0] AND $day $date[1]))
                {
                    
$post['age']--;
                }

                if (
$post['age'] < 101)
                {
                    
$gotage["$post[userid]"] = $post['age'];
                }
                else
                {
                    unset(
$post['age']);
                }
            }
            else
            {
                
$post['age'] = $gotage["$post[userid]"];
            }
        }
        
$post['musername'] = fetch_musername($post);
        
$post['rank'] = iif($post['leaderid']==$post['userid'], "Group Leader""nope");
        
$post['gender'] = "<img src=\"$stylevar[imgdir_misc]/$post[field24].gif\" alt=\"$post[field24]\" />";
        
$post['location'] = $post[field2];
        
$post['spacer1'] = iif($post['age'] AND $post['gender'], "/""");
        
$post['spacer2'] = iif($post['gender'] AND $post['location'], "/""");
        
$post['showsignature'] = iif($post['signature'], TRUEFALSE);
        
$post['postcount'] = $cell;

        
$forum['allowposting'] = TRUE;
        
$SHOWQUICKREPLY TRUE;

        
$postbit construct_postbit($post$template);
        
//extract($post);

    
//got all that info 


Marco van Herwaarden 01-15-2005 03:36 PM

Maybe change to:
PHP Code:

$postbit .= construct_postbit($post$template); 


1 question is it showing the first or the last?

sabret00the 01-15-2005 03:57 PM

last one, but that fixed it, thank you soooo much :)

Marco van Herwaarden 01-15-2005 04:09 PM

NP
Glad to help.

Have feeling you can repay soon enough :)


All times are GMT. The time now is 09:49 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02246 seconds
  • Memory Usage 1,757KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete