MyBB Community Forums

Full Version: Php Vs Template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can i put php code into template by editing from ACP template ??

i tryp put <? include '../stats.php'; ?> in template index but that not works..
You cannot use PHP code in templates, as far as I know. You will have to edit the php files manually. What are you trying to do ?
i want to put php script at Board Statistic,such as including file from other directory.If can't edited from ACP there must by php itself,so do i need edit index.php ?? if so where i must put a line php code ??

exm:

// Build the forum statistics to show on the index page.
eval("\$forumstats = \"".$templates->get("index_stats")."";");


php code:
include '../stats.php';
So you want to include the states page into some other external page?

Well usually we include everything at the start of the file.

However i believe you are trying to show stats in the index page of MyBB. Well including stats.php in index.php will cause a blank page i guess it wont work properly, so if you can specify what stats you want to show on MyBB index if this was your case tell us so that we give only the needed codes.

regards
I have another code but hard to explain,because i need to include for each script.I have member already register whit one database,but after install myBB i need data member (username,password) automatically insert into myBB database after registration and then can be use by myBB board also website..thats why i need to develope by follow the rules

stats.php:
<?php //module to display the top users
  include "../connect.php";
  if(!isset($start))
  {
    $start=0;
  }
  $order="SELECT * from ext_users";
  $order2=mysql_query($order);
  $d=0;
  $f=0;
  $g=1;

  while($order3=mysql_fetch_array($order2))
  {
    if($f%20==0)
    {
      $g++;
    }
    $d=$d+1;
    $f++;
  }
  print "&nbsp; <table border='0' cellspacing=1 width='100%' align=center bgcolor=#333333><tr><td bgcolor=#484848 align=center>Player</td><td bgcolor=#484848 align=center>Monster</td><td bgcolor=#484848 align=center>Result</td></tr>";
  $getbattlerecords="SELECT * from ext_battlerecords order by ID DESC Limit 0, 5";
  $getbattlerecords2=mysql_query($getbattlerecords) or die("Could not query players");
  while($getbattlerecords3=mysql_fetch_array($getbattlerecords2))
  {
    $getbattlerecords3[attname]=strip_tags($getbattlerecords3[attname]);


	$command2 = "SELECT * from ext_users where ID='$getbattlerecords3[victimid]'";
    $query2 = mysql_query($command2)
	or die($db_error);
	$fortinfo = mysql_fetch_array($query2);
	 $command1 = "SELECT * from gh_box where idname='$fortinfo[playername]'";
    $query1 = mysql_query($command1)
		or die($db_error);
    $playerinfo = mysql_fetch_array($query1);
    print "&nbsp; <tr><td style=background-color:#333333
 onMouseover=\"this.style.backgroundColor='#FF9900';\"
 onMouseout=this.style.backgroundColor='#333333';><a href=javascript:openpop('profile.php?name=$getbattlerecords3[attname]')>$getbattlerecords3[attname]</a></td><td align=center style=background-color:#333333
 onMouseover=\"this.style.backgroundColor='#FF9900';\"
 onMouseout=this.style.backgroundColor='#333333';><a href=index.box?url=$playerinfo[domain] target=_blank>$playerinfo[domain]</a></td><td style=background-color:#333333
 onMouseover=\"this.style.backgroundColor='#FF9900';\"
 onMouseout=this.style.backgroundColor='#333333';>$getbattlerecords3[result]</td></tr>";
  }
  print "</table>";
?>