vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   LIMIT query using a variable (https://vborg.vbsupport.ru/showthread.php?t=56817)

assassingod 09-06-2003 06:14 PM

LIMIT query using a variable
 
Im writing a hack that depending on the number entered in vBOptions, will limit the ammount of TR/TD tags there are using a query. I've tried this code:

PHP Code:

$uploadcode $DB_site->query("SELECT uploadcrap FROM portfolio LIMIT $numofportfolio"); 

Then I use $uploadcode[uploadcrap] in the template
But this only shows one row of code when I entered 5 in options.

Anyone shed some light on this

Xenon 09-06-2003 07:51 PM

you shouldn't get a single row, as your using an DB result and not a normal array.

you have to add a whileloop fetch_array afterwards :)

assassingod 09-06-2003 08:29 PM

Good idea, I'll try that - thanks

assassingod 09-06-2003 08:48 PM

Ok, here is the code i'm using now:

PHP Code:

$uploadcode $DB_site->query("SELECT uploadcrap FROM portfolio LIMIT $numofportfolio");
  while(
$uploadcodes $DB_site->fetch_array($uploadcode)) {
   eval(
" \$codecrap = \" " .gettemplate("codecrap_ap")."\";");


Then in the codecrap_ap template, I have $uploadcodes[uploadcrap] but I get an error:

"Warning: mysql_fetch_array supplied argument is not a valid MySQL result resource in db_mysql.php

Any ideas why?

Xenon 09-06-2003 08:52 PM

are you sure $numofportfolio is set at least at 1?

also in your eval code you missed a .

assassingod 09-06-2003 08:54 PM

$numofportfolio currently is set at 5

And thanks, I was copying off another screen:rolleyes:

assassingod 09-11-2003 06:42 PM

bump


All times are GMT. The time now is 12:21 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.01017 seconds
  • Memory Usage 1,721KB
  • 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
  • (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