vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Stepping through a mysql database (https://vborg.vbsupport.ru/showthread.php?t=61803)

BeyRevRa 02-22-2004 10:28 PM

Stepping through a mysql database
 
I need to find a way to get this to work in vbulletin. I'm working with a friend of mine on his site, and he needs a section added, that will list the top 10 of certain things, as well as a full list of some other data. normally, all I have to do is something like

$msResult=mysql_query("select * from my_table order by created desc;");
while($msData=mysql_fetch_array($msResult))
{ echo $msData['created'] . "<br>";
}

and it will echo out all the data in a nice (ugly) list.

I'm trying to do this in a vbulletin template, and any code that escapes into php gets ignored. I tried to create two templates, and print out one template, perform my code in the php file itself, and print out another template, but it would neve print the second template. what is the best way to add your own code to step through a database, but still keep it in the template format that all the other pages use?

assassingod 02-22-2004 10:32 PM

For vB2
PHP Code:

  $msResult $DB_site->query("
  SELECT *
  FROM my_table
  ORDER BY created DESC
  "
);
  while(
$msData $DB_site->fetch_array($msResult))
  {
  eval(
"\$variable .= \"".gettemplate('templatename')."\";");
  } 

Create 'templatename' template with the $msData variables inside, then use $variable in a template of your choice

For vB3:
PHP Code:

  $msResult $DB_site->query("
  SELECT *
  FROM my_table
  ORDER BY created DESC
  "
);
  while(
$msData $DB_site->fetch_array($msResult))
  {
  eval(
'$variable .= "' fetch_template('templatename') . '";');
  } 

Same applies for this.

BeyRevRa 02-23-2004 09:30 PM

thanks man, works like a charm, don't know why I didn't think of that earlier.


All times are GMT. The time now is 03:41 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.01520 seconds
  • Memory Usage 1,717KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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