vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Query results above header... (https://vborg.vbsupport.ru/showthread.php?t=68853)

Doc203 08-29-2004 10:35 PM

Query results above header...
 
I have a php script with a query on it and if I call the page up with a "basic page" template the results are always at the top of the page, above the header etc and I want the results to show in the body of the page. Any Ideas?

Doc203 08-30-2004 01:43 AM

Here is a link: My Test Page

Here is the php script:
PHP Code:

<?PHP
$templatesused 
"postdate";
require(
"./global.php");


$start_date "2004-07-01 00:00:00";
$end_date "2004-07-31 00:00:00";


$stmt $DB_site->query("SELECT COUNT(post.postid) AS count, user.username
FROM post
LEFT JOIN user ON (user.userid = post.userid)
AND (UNIX_TIMESTAMP('
$start_date')) <= post.dateline
AND post.dateline <= (UNIX_TIMESTAMP('
$end_date'))
GROUP BY user.userid ORDER BY count DESC, username"
);
echo 
"<table border=1 cellspacing=0>";
$result = ($stmt) or die (mysql_error()."<br />Couldn't execute query: $stmt"); 
while(
$row mysql_fetch_row($result))
{
   echo 
"<tr>";
   for(
$i 0$i mysql_num_fields($result); $i++)
   {
       echo 
"<td>" $row[$i] . "</td>";
   }
   echo 
"</tr>";
     }

     echo 
"</table>";
 
eval(
'print_output("' fetch_template('TEST') . '");'); 
eval(
'$navbar = "' fetch_template('navbar') . '";'); 
?>

and the template:
HTML Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">Title</td>
</tr>
<tr>
<td class="alt1">Text</td>
</tr>
</table>

$footer
</body>
</html>

Can I just assign a variable in Includes_start and call it in the template?

rake 08-30-2004 09:23 AM

you can never output anything via an echo or print command. replace echo with a variable, ($myvar = "<tr>"; for example) and then place that variable in your test template.

Doc203 08-30-2004 10:47 AM

So can I assign a variable to this part of the scritp and then call that variable in a template?

PHP Code:


   echo 
"<tr>"
   for(
$i 0$i mysql_num_fields($result); $i++) 
   { 
       echo 
"<td>" $row[$i] . "</td>"
   } 
   echo 
"</tr>"
     } 

     echo 
"</table>"

I tried adding this to my phpinclude_start template, so I could call the variable in my templates and it worked, but I would get random database errors I am assuming from too many mysql connections being as it was running the query everytime that ANY page was loaded.
PHP Code:

ob_start();
include(
"postcountdate.php");
$postcount ob_get_contents();
ob_end_clean(); 

I guess my problem is defining a php variable so it can be called in a template. Thanks for the help.

rake 08-30-2004 01:57 PM

You don't need to do that. Any variable in the script can be used in a template.


All times are GMT. The time now is 12:22 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.00972 seconds
  • Memory Usage 1,738KB
  • 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
  • (1)bbcode_html_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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