vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Collecting multiple Db info (https://vborg.vbsupport.ru/showthread.php?t=74862)

Adrian Schneider 01-22-2005 07:04 AM

Collecting multiple Db info
 
Okay I'm trying to get ratings from db and put them into a table. For some reason I only get the first row, here is what I have.

PHP Code:

$standings=mysql_query("select * from user ORDER BY rating DESC LIMIT 8");
while(
$rows=mysql_fetch_array($standings))
{
  
$player=$rows['username'];
  
$rating=$rows["rating"];
  
$id=$rows['userid'];
$standingbit "<tr><td><a href=http://www.starcraftdream.com/forums/member.php?u=$id>$player</a></td><td>$rating</td></tr>";


($standingbit is inserted into the template between first row and </table>

I could get this to work with echo easily enough, but not with templates. :(

cinq 01-22-2005 07:11 AM

I think it's the query.
What's your table for user like?

U mentioned using templates, so you are querying the default 'user' table of vb ?
You've added a rating field ?

Guy G 01-22-2005 07:34 AM

PHP Code:

$standings=mysql_query("select * from user ORDER BY rating DESC LIMIT 8"); 
while (
$rows mysql_fetch_array($standings)) 

  
$player $rows['username']; 
  
$rating $rows["rating"]; 
  
$id $rows['userid']; 
  
$standingbit "<tr><td><a href=http://www.starcraftdream.com/forums/member.php?u=$id>$player</a></td><td>$rating</td></tr>";


try that..

Dean C 01-22-2005 10:45 AM

PHP Code:

 $standings=mysql_query("select * from user ORDER BY rating DESC LIMIT 8");
while(
$rows=mysql_fetch_array($standings))
{
  
$player=$rows['username'];
  
$rating=$rows["rating"];
  
$id=$rows['userid'];
$standingbit .= "<tr><td><a href=http://www.starcraftdream.com/forums/member.php?u=$id>$player</a></td><td>$rating</td></tr>";


I have no idea about the other structure of your page so I'm guessing you echo $standbit somewhere else. Anyways the code above should work :) You forgot the concatenation operator ;) (.=)

Adrian Schneider 01-22-2005 04:34 PM

I love you guys. :)
$standingbit was in my template, user table was vbulletin, except for the added rating field, but all works. Thanks a bunch.

Adrian Schneider 01-23-2005 07:13 PM

How would I get it to display the result #?

[SOLVED] :)

Dean C 01-24-2005 09:53 AM

Glad you got it all worked out :)


All times are GMT. The time now is 01:01 PM.

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.01080 seconds
  • Memory Usage 1,730KB
  • 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
  • (7)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